Remove frontend redirection of legacy URIs without project Redirection of URIs with change number only is happening in the backend. Furthermore, since I622c4849 the mackend is handling URIs with and without the `/c/` prefix in the path. The frontend doesn't need anymore redirection logic. Bug: Issue 305565066 Release-Notes: skip Change-Id: I4ccff23305578e407390643c6c3a7bfa1950d9e1
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 ac35264..e0d4185 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -196,10 +196,6 @@ CHANGE_ID_QUERY: /^\/id\/(I[0-9a-f]{40})$/, - // Matches /c/<changeNum>/[*][/]. - CHANGE_LEGACY: /^\/c\/(\d+)\/?(.*)$/, - CHANGE_NUMBER_LEGACY: /^\/(\d+)\/?/, - // Matches // /c/<project>/+/<changeNum>/[<basePatchNum|edit>..][<patchNum|edit>]. // TODO(kaspern): Migrate completely to project based URLs, with backwards @@ -849,12 +845,6 @@ ); this.mapRoute( - RoutePattern.CHANGE_NUMBER_LEGACY, - 'handleChangeNumberLegacyRoute', - ctx => this.handleChangeNumberLegacyRoute(ctx) - ); - - this.mapRoute( RoutePattern.DIFF_EDIT, 'handleDiffEditRoute', ctx => this.handleDiffEditRoute(ctx), @@ -884,10 +874,6 @@ this.handleChangeRoute(ctx) ); - this.mapRoute(RoutePattern.CHANGE_LEGACY, 'handleChangeLegacyRoute', ctx => - this.handleChangeLegacyRoute(ctx) - ); - this.mapRoute( RoutePattern.AGREEMENTS, 'handleAgreementsRoute', @@ -1305,14 +1291,6 @@ this.redirect(ctx.path.replace(LEGACY_QUERY_SUFFIX_PATTERN, '')); } - handleChangeNumberLegacyRoute(ctx: PageContext) { - this.redirect( - '/c/' + - ctx.params[0] + - (ctx.querystring.length > 0 ? `?${ctx.querystring}` : '') - ); - } - handleChangeRoute(ctx: PageContext) { // Parameter order is based on the regex group number matched. const changeNum = Number(ctx.params[1]) as NumericChangeId; @@ -1464,26 +1442,6 @@ this.changeViewModel.setState(state); } - handleChangeLegacyRoute(ctx: PageContext) { - const changeNum = Number(ctx.params[0]) as NumericChangeId; - if (!changeNum) { - this.show404(); - return; - } - this.restApiService.getFromProjectLookup(changeNum).then(project => { - // Show a 404 and terminate if the lookup request failed. Attempting - // to redirect after failing to get the project loops infinitely. - if (!project) { - this.show404(); - return; - } - this.redirect( - `/c/${project}/+/${changeNum}/${ctx.params[1]}` + - (ctx.querystring.length > 0 ? `?${ctx.querystring}` : '') - ); - }); - } - handleLegacyLinenum(ctx: PageContext) { this.redirect(ctx.path.replace(LEGACY_LINENUM_PATTERN, '#$1')); }
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 234bf95..c4fb259 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
@@ -168,13 +168,11 @@ const unauthenticatedHandlers = [ 'handleBranchListRoute', 'handleChangeIdQueryRoute', - 'handleChangeNumberLegacyRoute', 'handleChangeRoute', 'handleCommentRoute', 'handleCommentsRoute', 'handleDiffRoute', 'handleDefaultRoute', - 'handleChangeLegacyRoute', 'handleDocumentationRedirectRoute', 'handleDocumentationSearchRoute', 'handleDocumentationSearchRedirectRoute', @@ -853,21 +851,6 @@ }); suite('CHANGE* / DIFF*', () => { - test('CHANGE_NUMBER_LEGACY', async () => { - // CHANGE_NUMBER_LEGACY: /^\/(\d+)\/?/, - await checkRedirect('/12345', '/c/12345'); - }); - - test('CHANGE_LEGACY', async () => { - // CHANGE_LEGACY: /^\/c\/(\d+)\/?(.*)$/, - stubRestApi('getFromProjectLookup').resolves('project' as RepoName); - await checkRedirect('/c/1234', '/c/project/+/1234/'); - await checkRedirect( - '/c/1234/comment/6789', - '/c/project/+/1234/comment/6789' - ); - }); - test('DIFF_LEGACY_LINENUM', async () => { await checkRedirect( '/c/1234/3..8/foo/bar@321',