Skip to content

Commit

Permalink
Bug 1749395 [wpt PR 32314] - URLPattern: Emit '{ }' when there is a p…
Browse files Browse the repository at this point in the history
…receding non-prefix '/'., a=testonly

Automatic update from web-platform-tests
URLPattern: Emit '{ }' when there is a preceding non-prefix '/'.

This CL fixes another problem where generating a pattern string
accidentally changes the meaning of the pattern:

whatwg/urlpattern#145 (comment)

In this case we want to make sure that a character that can be treated
as an implicit group prefix, e.g. `/`, is not incorrectly converted into
a prefix.  For example, if the original string is `/{:foo?}` we don't
want to generate `/:foo?` since that would make the `/` optional.

This CL also includes an additional fix that permits emitting `*` for
wildcards when there is a prefix.  Previously we were being too
conservative in some situations.  For example, we can emit `*/*` instead
of `*/(.*)`.

Fixed: 1285620
Change-Id: Idef288bdfdfaa0ae60f320ec326ee2f07d448681
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3378528
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/main@{#957730}

--

wpt-commits: 4928cc8d516868267da4be9a5b9a5f7856dd0b65
wpt-pr: 32314
  • Loading branch information
wanderview authored and moz-wptsync-bot committed Feb 5, 2022
1 parent 1cfac2a commit 8d7bcc8
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2508,15 +2508,15 @@
"pattern": [{ "pathname": "{:foo}{(.*)bar}" }],
"inputs": [{ "pathname": "foobarbaz" }],
"expected_obj": {
"pathname": ":foo{(.*)bar}"
"pathname": ":foo{*bar}"
},
"expected_match": null
},
{
"pattern": [{ "pathname": "{:foo}{bar(.*)}" }],
"inputs": [{ "pathname": "foobarbaz" }],
"expected_obj": {
"pathname": ":foo{bar(.*)}"
"pathname": ":foo{bar*}"
},
"expected_match": {
"pathname": { "input": "foobarbaz", "groups": { "foo": "foo", "0": "baz" }}
Expand Down Expand Up @@ -2636,5 +2636,34 @@
"expected_match": {
"pathname": { "input": "bazbar", "groups": { "foo": "baz" }}
}
},
{
"pattern": [{ "pathname": "*/*" }],
"inputs": [{ "pathname": "foo/bar" }],
"expected_match": {
"pathname": { "input": "foo/bar", "groups": { "0": "foo", "1": "bar" }}
}
},
{
"pattern": [{ "pathname": "*\\/*" }],
"inputs": [{ "pathname": "foo/bar" }],
"expected_obj": {
"pathname": "*/{*}"
},
"expected_match": {
"pathname": { "input": "foo/bar", "groups": { "0": "foo", "1": "bar" }}
}
},
{
"pattern": [{ "pathname": "*/{*}" }],
"inputs": [{ "pathname": "foo/bar" }],
"expected_match": {
"pathname": { "input": "foo/bar", "groups": { "0": "foo", "1": "bar" }}
}
},
{
"pattern": [{ "pathname": "*//*" }],
"inputs": [{ "pathname": "foo/bar" }],
"expected_match": null
}
]

0 comments on commit 8d7bcc8

Please sign in to comment.