Skip to content

Commit

Permalink
URL: URL.canParse()
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk authored and cookiecrook committed Mar 29, 2023
1 parent 9a9dc7b commit aed020c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions url/url-statics-canparse.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// This intentionally does not use resources/urltestdata.json to preserve resources.
[
{
"url": undefined,
"base": undefined,
"expected": false
},
{
"url": "a:b",
"base": undefined,
"expected": true
},
{
"url": undefined,
"base": "a:b",
"expected": false
},
{
"url": "a:/b",
"base": undefined,
"expected": true
},
{
"url": undefined,
"base": "a:/b",
"expected": true
},
{
"url": "https://test:test",
"base": undefined,
"expected": false
},
{
"url": "a",
"base": "https://b/",
"expected": true
}
].forEach(({ url, base, expected }) => {
test(() => {
assert_equals(URL.canParse(url, base), expected);
}, `URL.canParse(${url}, ${base})`);
});

0 comments on commit aed020c

Please sign in to comment.