Skip to content

Commit

Permalink
url: overload canParse V8 fast api method
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Aug 1, 2023
1 parent 9df9c71 commit a0bdd05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> target,
Expand Down
1 change: 0 additions & 1 deletion typings/internalBinding/url.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a0bdd05

Please sign in to comment.