Skip to content

Commit

Permalink
Implement URL.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Mar 23, 2024
1 parent bfcfe9a commit fda732a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/workerd/api/tests/url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9769,3 +9769,16 @@ export const urlPatternFun = {
}
}
};

export const urlParseStatic = {
test() {
const url = URL.parse('http://example.org');
strictEqual(url.protocol, 'http:');
strictEqual(url.host, 'example.org');

const url2 = URL.parse('foo', 'http://example.org');
strictEqual(url2.protocol, 'http:');
strictEqual(url2.host, 'example.org');
strictEqual(url2.pathname, '/foo');
}
};
1 change: 1 addition & 0 deletions src/workerd/api/url-standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class URL: public jsg::Object {
JSG_METHOD_NAMED(toJSON, getHref);
JSG_METHOD_NAMED(toString, getHref);
JSG_STATIC_METHOD(canParse);
JSG_STATIC_METHOD_NAMED(parse, constructor);

JSG_TS_OVERRIDE(URL {
constructor(url: string | URL, base?: string | URL);
Expand Down

0 comments on commit fda732a

Please sign in to comment.