Skip to content

Commit

Permalink
URLPattern: Emit {} when plain text follows a :foo group.
Browse files Browse the repository at this point in the history
This CL fixes another problem case from:

whatwg/urlpattern#145

In this case we need to detect when fixed text following a `:foo` group
could be mistaken as party of the name.  When this happens we should
emit `{ }` braces around the group to isolate it.  For example,
`{:foo}bar` instead of `:foobar`.

Bug: 1263673
Change-Id: I9c9bfb736c6e8880bceeae9280f0fc30f794cea8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3321520
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/main@{#950813}
  • Loading branch information
wanderview authored and pull[bot] committed Feb 23, 2024
1 parent 55cd9b3 commit 1167643
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions urlpattern/resources/urlpatterntestdata.json
Expand Up @@ -2565,5 +2565,22 @@
"expected_match": {
"pathname": { "input": "foobar", "groups": { "foo": "foo" }}
}
},
{
"pattern": [{ "pathname": "{:foo}bar" }],
"inputs": [{ "pathname": "foobar" }],
"expected_match": {
"pathname": { "input": "foobar", "groups": { "foo": "foo" }}
}
},
{
"pattern": [{ "pathname": ":foo\\bar" }],
"inputs": [{ "pathname": "foobar" }],
"expected_obj": {
"pathname": "{:foo}bar"
},
"expected_match": {
"pathname": { "input": "foobar", "groups": { "foo": "foo" }}
}
}
]

0 comments on commit 1167643

Please sign in to comment.