Skip to content

Commit a484fee

Browse files
authored
Revert "perf: improve URL validation performance (#52353)"
This reverts commit d5f355a.
1 parent daac048 commit a484fee

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

packages/next/src/server/app-render/validate-url.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
const DUMMY_ORIGIN = 'http://n'
22
const INVALID_URL_MESSAGE = 'Invalid request URL'
33

4-
// URL.canParse is supported on Node 19 and 20.
5-
// Node 18 backport is pending.
6-
// Reference: https://github.com/nodejs/node/pull/48345
7-
const supportsCanParse = URL.hasOwnProperty('canParse')
8-
94
export function validateURL(url: string | undefined): string {
10-
if (url == null) {
5+
if (!url) {
116
throw new Error(INVALID_URL_MESSAGE)
127
}
13-
14-
if (supportsCanParse) {
15-
// @ts-ignore
16-
if (!URL.canParse(url, DUMMY_ORIGIN)) {
17-
throw new Error(INVALID_URL_MESSAGE)
18-
}
19-
20-
return url
21-
}
22-
238
try {
249
const parsed = new URL(url, DUMMY_ORIGIN)
2510
// Avoid origin change by extra slashes in pathname

0 commit comments

Comments
 (0)