url: fix error type
Currently whatwg URLs fail with an incorrect error when null is passed as the base. Adding a check before accessing a symbol for the URL makes the URL error correctly. Add test for it. PR-URL: https://github.com/nodejs/node/pull/19299 Fixes: https://github.com/nodejs/node/issues/19254 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
b80da63b99
commit
cc6abc6e84
@ -319,8 +319,7 @@ class URL {
|
||||
constructor(input, base) {
|
||||
// toUSVString is not needed.
|
||||
input = `${input}`;
|
||||
if (base !== undefined &&
|
||||
(!base[searchParams] || !base[searchParams][searchParams])) {
|
||||
if (base !== undefined) {
|
||||
base = new URL(base);
|
||||
}
|
||||
parse(this, input, base);
|
||||
|
@ -22,6 +22,8 @@ const failureTests = tests.filter((test) => test.failure).concat([
|
||||
{ input: null },
|
||||
{ input: new Date() },
|
||||
{ input: new RegExp() },
|
||||
{ input: 'test', base: null },
|
||||
{ input: 'http://nodejs.org', base: null },
|
||||
{ input: () => {} }
|
||||
]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user