URLPattern: Add tests cases for patterns with empty groups.
This CL adds tests for more cases raised in:
https://github.com/WICG/urlpattern/issues/145
It turns out we don't need any further code changes to pass these test
cases since the parser already removes empty groups.
Bug: 1263673
Change-Id: I7b8da0da23e30780a09fc5132d36f4154b42b0db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3321903
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/main@{#950832}
diff --git a/urlpattern/resources/urlpatterntestdata.json b/urlpattern/resources/urlpatterntestdata.json
index 332637c..75a58e3 100644
--- a/urlpattern/resources/urlpatterntestdata.json
+++ b/urlpattern/resources/urlpatterntestdata.json
@@ -2582,5 +2582,45 @@
"expected_match": {
"pathname": { "input": "foobar", "groups": { "foo": "foo" }}
}
+ },
+ {
+ "pattern": [{ "pathname": ":foo{}(.*)" }],
+ "inputs": [{ "pathname": "foobar" }],
+ "expected_obj": {
+ "pathname": "{:foo}(.*)"
+ },
+ "expected_match": {
+ "pathname": { "input": "foobar", "groups": { "foo": "f", "0": "oobar" }}
+ }
+ },
+ {
+ "pattern": [{ "pathname": ":foo{}bar" }],
+ "inputs": [{ "pathname": "foobar" }],
+ "expected_obj": {
+ "pathname": "{:foo}bar"
+ },
+ "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" }}
+ }
+ },
+ {
+ "pattern": [{ "pathname": "*{}**?" }],
+ "inputs": [{ "pathname": "foobar" }],
+ "expected_obj": {
+ "pathname": "*(.*)?"
+ },
+ "expected_match": {
+ "pathname": { "input": "foobar", "groups": { "0": "foobar", "1": "" }}
+ }
}
]