Skip to content

Commit

Permalink
revert opaque host change
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jan 6, 2025
1 parent 580374b commit da9a991
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/url_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(
// - baseURL has an opaque path; and
// - the result of running is an absolute pathname given result["pathname"]
// and type is false,
if (base_url && base_url->has_opaque_path &&
if (base_url && !base_url->has_opaque_path &&
!url_pattern_helpers::is_absolute_pathname(*result.pathname, type)) {
// Let baseURLPath be the result of running process a base URL string
// given the result of URL path serializing baseURL and type.
Expand Down
82 changes: 82 additions & 0 deletions tests/wpt/urlpatterntestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,32 @@
"pathname": { "input": "/bar", "groups": {}}
}
},
{
"pattern": [{ "pathname": "./foo/bar", "baseURL": "https://example.com" }],
"inputs": [{ "pathname": "foo/bar", "baseURL": "https://example.com" }],
"exactly_empty_components": [ "port" ],
"expected_obj": {
"pathname": "/foo/bar"
},
"expected_match": {
"protocol": { "input": "https", "groups": {}},
"hostname": { "input": "example.com", "groups": {}},
"pathname": { "input": "/foo/bar", "groups": {}}
}
},
{
"pattern": [{ "pathname": "", "baseURL": "https://example.com" }],
"inputs": [{ "pathname": "/", "baseURL": "https://example.com" }],
"exactly_empty_components": [ "port" ],
"expected_obj": {
"pathname": "/"
},
"expected_match": {
"protocol": { "input": "https", "groups": {}},
"hostname": { "input": "example.com", "groups": {}},
"pathname": { "input": "/", "groups": {}}
}
},
{
"pattern": [{ "pathname": "{/bar}", "baseURL": "https://example.com/foo/" }],
"inputs": [{ "pathname": "./bar", "baseURL": "https://example.com/foo/" }],
Expand All @@ -1257,11 +1283,50 @@
},
"expected_match": null
},
{
"pattern": [{ "pathname": "b", "baseURL": "https://example.com/foo/" }],
"inputs": [{ "pathname": "./b", "baseURL": "https://example.com/foo/" }],
"exactly_empty_components": [ "port" ],
"expected_obj": {
"pathname": "/foo/b"
},
"expected_match": {
"protocol": { "input": "https", "groups": {}},
"hostname": { "input": "example.com", "groups": {}},
"pathname": { "input": "/foo/b", "groups": {}}
}
},
{
"pattern": [{ "pathname": "foo/bar" }],
"inputs": [ "https://example.com/foo/bar" ],
"expected_match": null
},
{
"pattern": [{ "pathname": "foo/bar", "baseURL": "https://example.com" }],
"inputs": [ "https://example.com/foo/bar" ],
"exactly_empty_components": [ "port" ],
"expected_obj": {
"pathname": "/foo/bar"
},
"expected_match": {
"protocol": { "input": "https", "groups": {}},
"hostname": { "input": "example.com", "groups": {}},
"pathname": { "input": "/foo/bar", "groups": {}}
}
},
{
"pattern": [{ "pathname": ":name.html", "baseURL": "https://example.com" }],
"inputs": [ "https://example.com/foo.html"] ,
"exactly_empty_components": [ "port" ],
"expected_obj": {
"pathname": "/:name.html"
},
"expected_match": {
"protocol": { "input": "https", "groups": {}},
"hostname": { "input": "example.com", "groups": {}},
"pathname": { "input": "/foo.html", "groups": { "name": "foo" }}
}
},
{
"pattern": [{ "search": "q=caf%C3%A9" }],
"inputs": [{ "search": "q=café" }],
Expand Down Expand Up @@ -2072,6 +2137,23 @@
},
"expected_match": null
},
{
"pattern": [ "data{\\:}channel.html", "https://example.com" ],
"inputs": [ "https://example.com/data:channel.html" ],
"exactly_empty_components": [ "port" ],
"expected_obj": {
"protocol": "https",
"hostname": "example.com",
"pathname": "/data\\:channel.html",
"search": "*",
"hash": "*"
},
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/data:channel.html", "groups": {} }
}
},
{
"pattern": [ "http://[\\:\\:1]/" ],
"inputs": [ "http://[::1]/" ],
Expand Down

0 comments on commit da9a991

Please sign in to comment.