Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
116 changes: 116 additions & 0 deletions tests/wpt/urlpattern-generate-test-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[
{
"pattern": { "pathname": "/foo" },
"component": "invalid",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/foo" },
"component": "pathname",
"groups": {},
"expected": "/foo"
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": { "foo": "bar" },
"expected": "/bar"
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": { "foo": "🍅" },
"expected": "/%F0%9F%8D%85"
},
{
"pattern": { "hostname": "{:foo}.example.com" },
"component": "hostname",
"groups": { "foo": "🍅" },
"expected": "xn--fi8h.example.com"
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/foo/:bar" },
"component": "pathname",
"groups": { "bar": "baz" },
"expected": "/foo/baz"
},
{
"pattern": { "pathname": "/foo:bar" },
"component": "pathname",
"groups": { "bar": "baz" },
"expected": "/foobaz"
},
{
"pattern": { "pathname": "/:foo/:bar" },
"component": "pathname",
"groups": { "foo": "baz", "bar": "qux" },
"expected": "/baz/qux"
},
{
"pattern": "https://example.com/:foo",
"component": "pathname",
"groups": { "foo": " " },
"expected": "/%20"
},
{
"pattern": "original-scheme://example.com/:foo",
"component": "pathname",
"groups": { "foo": " " },
"expected": "/ "
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": { "foo": "bar/baz" },
"expected": null
},
{
"pattern": { "pathname": "*" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/{foo}+" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/{foo}?" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/{foo}*" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/(regexp)" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/([^\\/]+?)" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "port": "([^\\:]+?)" },
"component": "port",
"groups": {},
"expected": null
}
]
105 changes: 105 additions & 0 deletions tests/wpt/urlpatterntestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,41 @@
"hostname": { "input": "xn--caf-dma.com", "groups": {}}
}
},
{
"pattern": ["http://\uD83D\uDEB2.com/"],
"inputs": ["http://\uD83D\uDEB2.com/"],
"exactly_empty_components": [ "port" ],
"expected_obj": {
"protocol": "http",
"hostname": "xn--h78h.com",
"pathname": "/"
},
"expected_match": {
"protocol": { "input": "http", "groups": {}},
"hostname": { "input": "xn--h78h.com", "groups": {}},
"pathname": { "input": "/", "groups": {}}
}
},
{
"pattern": ["http://\uD83D \uDEB2"],
"expected_obj": "error"
},
{
"pattern": [{"hostname":"\uD83D \uDEB2"}],
"expected_obj": "error"
},
{
"pattern": [{"pathname":"\uD83D \uDEB2"}],
"inputs": [],
"expected_obj": {
"pathname": "%EF%BF%BD%20%EF%BF%BD"
},
"expected_match": null
},
{
"pattern": [{"pathname":":\uD83D \uDEB2"}],
"expected_obj": "error"
},
{
"pattern": [{"pathname":":a\uDB40\uDD00b"}],
"inputs": [],
Expand Down Expand Up @@ -1439,6 +1474,10 @@
"pathname": { "input": "8675309", "groups": { "number": "8675309" }}
}
},
{
"pattern": [{ "pathname": "/(\\m)" }],
"expected_obj": "error"
},
{
"pattern": [{ "pathname": "/foo!" }],
"inputs": [{ "pathname": "/foo!" }],
Expand Down Expand Up @@ -2928,5 +2967,71 @@
"search": { "input": "q=*&v=?&hmm={}&umm=()", "groups": {} },
"hash": { "input": "foo", "groups": {} }
}
},
{
"pattern": [{ "pathname": "/([[a-z]--a])" }],
"inputs": [{ "pathname": "/a" }],
"expected_match": null
},
{
"pattern": [{ "pathname": "/([[a-z]--a])" }],
"inputs": [{ "pathname": "/z" }],
"expected_match": {
"pathname": { "input": "/z", "groups": { "0": "z" } }
}
},
{
"pattern": [{ "pathname": "/([\\d&&[0-1]])" }],
"inputs": [{ "pathname": "/0" }],
"expected_match": {
"pathname": { "input": "/0", "groups": { "0": "0" } }
}
},
{
"pattern": [{ "pathname": "/([\\d&&[0-1]])" }],
"inputs": [{ "pathname": "/3" }],
"expected_match": null
},
{
"pattern": [{ "protocol": "http", "hostname": "example.com/ignoredpath" }],
"inputs": ["http://example.com/"],
"expected_obj": {
"protocol": "http",
"hostname": "example.com",
"pathname": "*"
},
"expected_match": {
"protocol": { "input": "http", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": { "0": "/" } }
}
},
{
"pattern": [{ "protocol": "http", "hostname": "example.com\\?ignoredsearch" }],
"inputs": ["http://example.com/"],
"expected_obj": {
"protocol": "http",
"hostname": "example.com",
"search": "*"
},
"expected_match": {
"protocol": { "input": "http", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": { "0": "/" } }
}
},
{
"pattern": [{ "protocol": "http", "hostname": "example.com#ignoredhash" }],
"inputs": ["http://example.com/"],
"expected_obj": {
"protocol": "http",
"hostname": "example.com",
"hash": "*"
},
"expected_match": {
"protocol": { "input": "http", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": { "0": "/" } }
}
}
]
Loading