diff --git a/lib/internal/url.js b/lib/internal/url.js index 6aa9260990fecb..73168f40e13c64 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1054,10 +1054,10 @@ class URL { url = `${url}`; if (base !== undefined) { - return bindingUrl.canParseWithBase(url, `${base}`); + base = `${base}`; } - return bindingUrl.canParse(url); + return bindingUrl.canParse(url, base); } } diff --git a/src/node_url.cc b/src/node_url.cc index 35a7855035a2f1..21127c3172d7e4 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -360,13 +360,14 @@ void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data, SetMethodNoSideEffect(isolate, target, "getOrigin", GetOrigin); SetMethod(isolate, target, "parse", Parse); SetMethod(isolate, target, "update", Update); - SetFastMethodNoSideEffect( - isolate, target, "canParse", CanParse, &fast_can_parse_); - SetFastMethodNoSideEffect(isolate, - target, - "canParseWithBase", - CanParse, - &fast_can_parse_with_base_); + + const v8::CFunction fast_can_parse_methods[] = {fast_can_parse_, fast_can_parse_with_base_}; + SetFastMethodNoSideEffectOverloads( + isolate, + target, + "canParse", + CanParse, + {fast_can_parse_methods, 2}); } void BindingData::CreatePerContextProperties(Local target, diff --git a/typings/internalBinding/url.d.ts b/typings/internalBinding/url.d.ts index 90c8d5e869b479..4c8ae2ab1508f0 100644 --- a/typings/internalBinding/url.d.ts +++ b/typings/internalBinding/url.d.ts @@ -6,7 +6,6 @@ declare function InternalBinding(binding: 'url'): { domainToASCII(input: string): string; domainToUnicode(input: string): string; canParse(input: string): boolean; - canParseWithBase(input: string, base: string): boolean; format(input: string, fragment?: boolean, unicode?: boolean, search?: boolean, auth?: boolean): string; parse(input: string, base?: string): string | false; update(input: string, actionType: typeof urlUpdateActions, value: string): string | false;