Drop noop ,n,z from query URLs
Bug: Issue 7673
Change-Id: I495dac05b63e22cf76539baa103bd8f75c691ed0
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.js b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
index 8a59fa6..8bc2a0b 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
@@ -91,6 +91,13 @@
QUERY: /^\/q\/([^,]+)(,(\d+))?$/,
+ /**
+ * Support vestigial params from GWT UI.
+ * @see Issue 7673.
+ * @type {!RegExp}
+ */
+ QUERY_LEGACY_SUFFIX: /^\/q\/.+,n,z$/,
+
// Matches /c/<changeNum>/[<basePatchNum>..][<patchNum>][/].
CHANGE_LEGACY: /^\/c\/(\d+)\/?(((-?\d+|edit)(\.\.(\d+|edit))?))?\/?$/,
CHANGE_NUMBER_LEGACY: /^\/(\d+)\/?/,
@@ -148,6 +155,8 @@
*/
const LEGACY_LINENUM_PATTERN = /@([ab]?\d+)$/;
+ const LEGACY_QUERY_SUFFIX_PATTERN = /,n,z$/;
+
// Polymer makes `app` intrinsically defined on the window by virtue of the
// custom element having the id "app", but it is made explicit here.
const app = document.querySelector('#app');
@@ -610,6 +619,9 @@
this._mapRoute(RoutePattern.PLUGIN_LIST, '_handlePluginListRoute', true);
+ this._mapRoute(RoutePattern.QUERY_LEGACY_SUFFIX,
+ '_handleQueryLegacySuffixRoute');
+
this._mapRoute(RoutePattern.QUERY, '_handleQueryRoute');
this._mapRoute(RoutePattern.DIFF_LEGACY_LINENUM, '_handleLegacyLinenum');
@@ -1020,6 +1032,10 @@
});
},
+ _handleQueryLegacySuffixRoute(ctx) {
+ this._redirect(ctx.path.replace(LEGACY_QUERY_SUFFIX_PATTERN, ''));
+ },
+
_handleChangeNumberLegacyRoute(ctx) {
this._redirect('/c/' + encodeURIComponent(ctx.params[0]));
},
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
index 12d9dea..2e86f73 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
@@ -161,6 +161,7 @@
'_handleProjectListFilterRoute',
'_handleProjectListOffsetRoute',
'_handleProjectRoute',
+ '_handleQueryLegacySuffixRoute',
'_handleQueryRoute',
'_handleRegisterRoute',
'_handleTagListFilterOffsetRoute',
@@ -586,6 +587,12 @@
});
});
+ test('_handleQueryLegacySuffixRoute', () => {
+ element._handleQueryLegacySuffixRoute({path: '/q/foo+bar,n,z'});
+ assert.isTrue(redirectStub.calledOnce);
+ assert.equal(redirectStub.lastCall.args[0], '/q/foo+bar');
+ });
+
suite('_handleRegisterRoute', () => {
test('happy path', () => {
const ctx = {params: ['/foo/bar']};