URLPattern: Don't emit `*` when it can be confused for a modifier.

This CL fixes a particular issue in an overall class of problems
described in:

https://github.com/WICG/urlpattern/issues/145

This particular CL only addresses the case where a wildcard could
mistakenly be interpreted as a modifier for a preceding group.  For
example, we should not change `(foo)(.*)` to `(foo)*`.

There will be more follow-up CLs to fix other issues mentioned in the
github issue.

Bug: 1263673
Change-Id: I5c99aa6b1fe46cc5905d823ef8184375b832c92a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3313642
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/main@{#947747}
diff --git a/urlpattern/resources/urlpatterntestdata.json b/urlpattern/resources/urlpatterntestdata.json
index b4f9dd7..f097edb 100644
--- a/urlpattern/resources/urlpatterntestdata.json
+++ b/urlpattern/resources/urlpatterntestdata.json
@@ -2455,5 +2455,29 @@
     "pattern": [],
     "inputs": [],
     "expected_match": { "inputs": [{}] }
+  },
+  {
+    "pattern": [{ "pathname": "(foo)(.*)" }],
+    "inputs": [{ "pathname": "foobarbaz" }],
+    "expected_match": {
+      "pathname": { "input": "foobarbaz", "groups": { "0": "foo", "1": "barbaz" }}
+    }
+  },
+  {
+    "pattern": [{ "pathname": "{(foo)bar}(.*)" }],
+    "inputs": [{ "pathname": "foobarbaz" }],
+    "expected_match": {
+      "pathname": { "input": "foobarbaz", "groups": { "0": "foo", "1": "baz" }}
+    }
+  },
+  {
+    "pattern": [{ "pathname": "(foo)?(.*)" }],
+    "inputs": [{ "pathname": "foobarbaz" }],
+    "expected_obj": {
+      "pathname": "(foo)?*"
+    },
+    "expected_match": {
+      "pathname": { "input": "foobarbaz", "groups": { "0": "foo", "1": "barbaz" }}
+    }
   }
 ]