Fix the QUERY route pattern to work well with unencoded commas

With change 356828 we have stopped universal double encoding. That
means route patterns have to work with unencoded commas. The QUERY
route pattern was using `[^,]` for matching the query, which would
not work anymore when using a query with a comma in it.

Note that searching for `,123` is still impossible, because we have
no way to decide whether this is supposed to be a search query or an
offset. The route patterns using `,something` suffixes should really
be changed to either use paths or query parameters.

Release-Notes: skip
Google-Bug-Id: b/267453810
Change-Id: I668e0fc1fc4a3e9ade9788fec9a55eb2cedf4a97
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
index 3dbd1a0..c0433dd 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -189,7 +189,7 @@
   // Matches /admin/repos/$REPO,tags with optional filter and offset.
   TAG_LIST: /^\/admin\/repos\/(.+),tags\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
 
-  QUERY: /^\/q\/([^,]+)(,(\d+))?$/,
+  QUERY: /^\/q\/(.+?)(,(\d+))?$/,
 
   /**
    * Support vestigial params from GWT UI.
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
index 3ca7bdc..87d100c 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
@@ -416,7 +416,7 @@
     });
 
     test('QUERY', async () => {
-      // QUERY: /^\/q\/([^,]+)(,(\d+))?$/,
+      // QUERY: /^\/q\/(.+?)(,(\d+))?$/,
       await checkUrlToState('/q/asdf', {
         ...createSearchViewState(),
         query: 'asdf',
@@ -430,6 +430,15 @@
         query: 'asdf',
         offset: '123',
       });
+      await checkUrlToState('/q/asdf,qwer', {
+        ...createSearchViewState(),
+        query: 'asdf,qwer',
+      });
+      await checkUrlToState('/q/asdf,qwer,123', {
+        ...createSearchViewState(),
+        query: 'asdf,qwer',
+        offset: '123',
+      });
     });
 
     test('QUERY_LEGACY_SUFFIX', async () => {