diff --git a/lib/internal/url.js b/lib/internal/url.js index 21c7c734b58475..8c83ca86c3fb98 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -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); diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index 928ac5d6a6c658..fd34fee1954d8c 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -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: () => {} } ]);