Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,16 @@ class URL {
this.#updateContext(bindingUrl.parse(input, base));
}

static parse(input, base = undefined) {
try {
const url = new URL(input, base);
return url;
/* eslint-disable-next-line no-unused-vars */
} catch (_) {
return null;
}
}

[inspect.custom](depth, opts) {
if (typeof depth === 'number' && depth < 0)
return this;
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/wpt/interfaces/url.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
interface URL {
constructor(USVString url, optional USVString base);

static URL? parse(USVString url, optional USVString base);
static boolean canParse(USVString url, optional USVString base);

stringifier attribute USVString href;
Expand Down