Skip to content

Commit a068ef4

Browse files
anonriggithub-actions[bot]
authored andcommitted
test: update web platform tests
1 parent 667c3cd commit a068ef4

File tree

2 files changed

+179
-0
lines changed

2 files changed

+179
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
[
2+
{
3+
"pattern": { "pathname": "/foo" },
4+
"component": "invalid",
5+
"groups": {},
6+
"expected": null
7+
},
8+
{
9+
"pattern": { "pathname": "/foo" },
10+
"component": "pathname",
11+
"groups": {},
12+
"expected": "/foo"
13+
},
14+
{
15+
"pattern": { "pathname": "/:foo" },
16+
"component": "pathname",
17+
"groups": { "foo": "bar" },
18+
"expected": "/bar"
19+
},
20+
{
21+
"pattern": { "pathname": "/:foo" },
22+
"component": "pathname",
23+
"groups": { "foo": "🍅" },
24+
"expected": "/%F0%9F%8D%85"
25+
},
26+
{
27+
"pattern": { "hostname": "{:foo}.example.com" },
28+
"component": "hostname",
29+
"groups": { "foo": "🍅" },
30+
"expected": "xn--fi8h.example.com"
31+
},
32+
{
33+
"pattern": { "pathname": "/:foo" },
34+
"component": "pathname",
35+
"groups": {},
36+
"expected": null
37+
},
38+
{
39+
"pattern": { "pathname": "/foo/:bar" },
40+
"component": "pathname",
41+
"groups": { "bar": "baz" },
42+
"expected": "/foo/baz"
43+
},
44+
{
45+
"pattern": { "pathname": "/foo:bar" },
46+
"component": "pathname",
47+
"groups": { "bar": "baz" },
48+
"expected": "/foobaz"
49+
},
50+
{
51+
"pattern": { "pathname": "/:foo/:bar" },
52+
"component": "pathname",
53+
"groups": { "foo": "baz", "bar": "qux" },
54+
"expected": "/baz/qux"
55+
},
56+
{
57+
"pattern": "https://example.com/:foo",
58+
"component": "pathname",
59+
"groups": { "foo": " " },
60+
"expected": "/%20"
61+
},
62+
{
63+
"pattern": "original-scheme://example.com/:foo",
64+
"component": "pathname",
65+
"groups": { "foo": " " },
66+
"expected": "/ "
67+
},
68+
{
69+
"pattern": { "pathname": "/:foo" },
70+
"component": "pathname",
71+
"groups": { "foo": "bar/baz" },
72+
"expected": null
73+
},
74+
{
75+
"pattern": { "pathname": "*" },
76+
"component": "pathname",
77+
"groups": {},
78+
"expected": null
79+
},
80+
{
81+
"pattern": { "pathname": "/{foo}+" },
82+
"component": "pathname",
83+
"groups": {},
84+
"expected": null
85+
},
86+
{
87+
"pattern": { "pathname": "/{foo}?" },
88+
"component": "pathname",
89+
"groups": {},
90+
"expected": null
91+
},
92+
{
93+
"pattern": { "pathname": "/{foo}*" },
94+
"component": "pathname",
95+
"groups": {},
96+
"expected": null
97+
},
98+
{
99+
"pattern": { "pathname": "/(regexp)" },
100+
"component": "pathname",
101+
"groups": {},
102+
"expected": null
103+
},
104+
{
105+
"pattern": { "pathname": "/([^\\/]+?)" },
106+
"component": "pathname",
107+
"groups": {},
108+
"expected": null
109+
},
110+
{
111+
"pattern": { "port": "([^\\:]+?)" },
112+
"component": "port",
113+
"groups": {},
114+
"expected": null
115+
}
116+
]

tests/wpt/urlpatterntestdata.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,41 @@
11211121
"hostname": { "input": "xn--caf-dma.com", "groups": {}}
11221122
}
11231123
},
1124+
{
1125+
"pattern": ["http://\uD83D\uDEB2.com/"],
1126+
"inputs": ["http://\uD83D\uDEB2.com/"],
1127+
"exactly_empty_components": [ "port" ],
1128+
"expected_obj": {
1129+
"protocol": "http",
1130+
"hostname": "xn--h78h.com",
1131+
"pathname": "/"
1132+
},
1133+
"expected_match": {
1134+
"protocol": { "input": "http", "groups": {}},
1135+
"hostname": { "input": "xn--h78h.com", "groups": {}},
1136+
"pathname": { "input": "/", "groups": {}}
1137+
}
1138+
},
1139+
{
1140+
"pattern": ["http://\uD83D \uDEB2"],
1141+
"expected_obj": "error"
1142+
},
1143+
{
1144+
"pattern": [{"hostname":"\uD83D \uDEB2"}],
1145+
"expected_obj": "error"
1146+
},
1147+
{
1148+
"pattern": [{"pathname":"\uD83D \uDEB2"}],
1149+
"inputs": [],
1150+
"expected_obj": {
1151+
"pathname": "%EF%BF%BD%20%EF%BF%BD"
1152+
},
1153+
"expected_match": null
1154+
},
1155+
{
1156+
"pattern": [{"pathname":":\uD83D \uDEB2"}],
1157+
"expected_obj": "error"
1158+
},
11241159
{
11251160
"pattern": [{"pathname":":a\uDB40\uDD00b"}],
11261161
"inputs": [],
@@ -1439,6 +1474,10 @@
14391474
"pathname": { "input": "8675309", "groups": { "number": "8675309" }}
14401475
}
14411476
},
1477+
{
1478+
"pattern": [{ "pathname": "/(\\m)" }],
1479+
"expected_obj": "error"
1480+
},
14421481
{
14431482
"pattern": [{ "pathname": "/foo!" }],
14441483
"inputs": [{ "pathname": "/foo!" }],
@@ -2928,5 +2967,29 @@
29282967
"search": { "input": "q=*&v=?&hmm={}&umm=()", "groups": {} },
29292968
"hash": { "input": "foo", "groups": {} }
29302969
}
2970+
},
2971+
{
2972+
"pattern": [{ "pathname": "/([[a-z]--a])" }],
2973+
"inputs": [{ "pathname": "/a" }],
2974+
"expected_match": null
2975+
},
2976+
{
2977+
"pattern": [{ "pathname": "/([[a-z]--a])" }],
2978+
"inputs": [{ "pathname": "/z" }],
2979+
"expected_match": {
2980+
"pathname": { "input": "/z", "groups": { "0": "z" } }
2981+
}
2982+
},
2983+
{
2984+
"pattern": [{ "pathname": "/([\\d&&[0-1]])" }],
2985+
"inputs": [{ "pathname": "/0" }],
2986+
"expected_match": {
2987+
"pathname": { "input": "/0", "groups": { "0": "0" } }
2988+
}
2989+
},
2990+
{
2991+
"pattern": [{ "pathname": "/([\\d&&[0-1]])" }],
2992+
"inputs": [{ "pathname": "/3" }],
2993+
"expected_match": null
29312994
}
29322995
]

0 commit comments

Comments
 (0)