Skip to content

Commit 6eeec3c

Browse files
authored
update urlpattern port parsing according to spec changes (#924)
1 parent 8211743 commit 6eeec3c

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

include/ada/parser-inl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ tl::expected<url_pattern<regex_provider>, errors> parse_url_pattern_impl(
9696
// TODO: Optimization opportunity.
9797
if (scheme::is_special(*processed_init->protocol)) {
9898
std::string_view port = processed_init->port.value();
99-
helpers::trim_c0_whitespace(port);
10099
if (std::to_string(scheme::get_special_port(*processed_init->protocol)) ==
101100
port) {
102101
processed_init->port->clear();

tests/wpt/urlpatterntestdata.json

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,10 +1167,11 @@
11671167
{
11681168
"pattern": [{ "protocol": "http", "port": "80 " }],
11691169
"inputs": [{ "protocol": "http", "port": "80" }],
1170-
"exactly_empty_components": ["port"],
1171-
"expected_match": {
1172-
"protocol": { "input": "http", "groups": {} }
1173-
}
1170+
"expected_obj": {
1171+
"protocol": "http",
1172+
"port": "80"
1173+
},
1174+
"expected_match": null
11741175
},
11751176
{
11761177
"pattern": [{ "protocol": "http", "port": "100000" }],
@@ -1194,6 +1195,34 @@
11941195
"port": { "input": "80", "groups": {}}
11951196
}
11961197
},
1198+
{
1199+
"pattern": [{ "port": "80" }],
1200+
"inputs": [{ "port": "8\t0" }],
1201+
"expected_match": {
1202+
"port": { "input": "80", "groups": {}}
1203+
}
1204+
},
1205+
{
1206+
"pattern": [{ "port": "80" }],
1207+
"inputs": [{ "port": "80x" }],
1208+
"expected_match": {
1209+
"port": { "input": "80", "groups": {}}
1210+
}
1211+
},
1212+
{
1213+
"pattern": [{ "port": "80" }],
1214+
"inputs": [{ "port": "80?x" }],
1215+
"expected_match": {
1216+
"port": { "input": "80", "groups": {}}
1217+
}
1218+
},
1219+
{
1220+
"pattern": [{ "port": "80" }],
1221+
"inputs": [{ "port": "80\\x" }],
1222+
"expected_match": {
1223+
"port": { "input": "80", "groups": {}}
1224+
}
1225+
},
11971226
{
11981227
"pattern": [{ "port": "(.*)" }],
11991228
"inputs": [{ "port": "invalid80" }],
@@ -1832,6 +1861,21 @@
18321861
"pathname": { "input": "/foo", "groups": {} }
18331862
}
18341863
},
1864+
{
1865+
"pattern": [ "https://{sub.}?example{.com/}foo" ],
1866+
"inputs": [ "https://example.com/foo" ],
1867+
"exactly_empty_components": [ "port" ],
1868+
"expected_obj": {
1869+
"protocol": "https",
1870+
"hostname": "{sub.}?example.com",
1871+
"pathname": "*"
1872+
},
1873+
"expected_match": {
1874+
"protocol": { "input": "https", "groups": {} },
1875+
"hostname": { "input": "example.com", "groups": {} },
1876+
"pathname": { "input": "/foo", "groups": { "0": "/foo" } }
1877+
}
1878+
},
18351879
{
18361880
"pattern": [ "{https://}example.com/foo" ],
18371881
"inputs": [ "https://example.com/foo" ],

0 commit comments

Comments
 (0)