Skip to content

Commit

Permalink
URLPattern: Escape pattern baseURL values.
Browse files Browse the repository at this point in the history
This addresses the problem described in this spec issue:

whatwg/urlpattern#170

And this spec PR:

whatwg/urlpattern#172

Bug: 1380534
Change-Id: I37b5f77e674f8c23ff59e6224d92c7a0d767e7cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020802
Commit-Queue: Ben Kelly <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1071919}
  • Loading branch information
wanderview authored and chromium-wpt-export-bot committed Nov 17, 2022
1 parent 67eef80 commit 77d95d5
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions urlpattern/resources/urlpatterntestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2794,5 +2794,50 @@
"inputs": [{ "pathname": "/FOO", "search": "BAR", "hash": "BAZ",
"baseURL": "https://example.com:8080" }],
"expected_obj": "error"
},
{
"pattern": [{ "search": "foo", "baseURL": "https://example.com/a/+/b" }],
"inputs": [{ "search": "foo", "baseURL": "https://example.com/a/+/b" }],
"exactly_empty_components": [ "username", "password", "port", "hash" ],
"expected_obj": {
"pathname": "/a/\\+/b"
},
"expected_match": {
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/a/+/b", "groups": {} },
"protocol": { "input": "https", "groups": {} },
"search": { "input": "foo", "groups": {} }
}
},
{
"pattern": [{ "hash": "foo", "baseURL": "https://example.com/?q=*&v=?&hmm={}&umm=()" }],
"inputs": [{ "hash": "foo", "baseURL": "https://example.com/?q=*&v=?&hmm={}&umm=()" }],
"exactly_empty_components": [ "username", "password", "port" ],
"expected_obj": {
"search": "q=\\*&v=\\?&hmm=\\{\\}&umm=\\(\\)"
},
"expected_match": {
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": {} },
"protocol": { "input": "https", "groups": {} },
"search": { "input": "q=*&v=?&hmm={}&umm=()", "groups": {} },
"hash": { "input": "foo", "groups": {} }
}
},
{
"pattern": [ "#foo", "https://example.com/?q=*&v=?&hmm={}&umm=()" ],
"inputs": [ "https://example.com/?q=*&v=?&hmm={}&umm=()#foo" ],
"exactly_empty_components": [ "username", "password", "port" ],
"expected_obj": {
"search": "q=\\*&v=\\?&hmm=\\{\\}&umm=\\(\\)",
"hash": "foo"
},
"expected_match": {
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": {} },
"protocol": { "input": "https", "groups": {} },
"search": { "input": "q=*&v=?&hmm={}&umm=()", "groups": {} },
"hash": { "input": "foo", "groups": {} }
}
}
]

0 comments on commit 77d95d5

Please sign in to comment.