Skip to content

Commit

Permalink
Add new pages to v1 redirect logic
Browse files Browse the repository at this point in the history
Fixes bug with incoming pages with locale being mistakenly redirected
  • Loading branch information
BobChao87 committed Dec 9, 2021
1 parent c7142ec commit 987b5e1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions middleware/oengus-v1-redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ import { Middleware } from '@nuxt/types';
const oengusV2Pages: Array<Array<string>> = [
// Homepage
[ ],
[ 'about' ],
[ 'calendar' ],
[ 'calendar', '*', '*' ],
[ 'marathon', '*' ],
[ 'marathon', '*', 'schedule' ],
[ 'news', 'kaspersky-partnership' ],
[ 'patrons' ],
[ 'user', '*' ],
];

const oengusV1Redirect: Middleware = function ({ $config, route, redirect, from }): void {
const oengusV1Redirect: Middleware = function ({ $config, route, from, redirect, localePath }): void {
if (!$config.env.DOMAIN_V1) {
return;
}
let to = route.path
// localePath is smart enough to only add/change a locale when necessary, this allows us to handle
// incoming requests that don't include the locale portion of the path without weird redirects
let to = localePath(route.path)
.split('/')
// Remove leading, trailing, and duplicated `/` portions
.filter(part => part)
Expand Down

0 comments on commit 987b5e1

Please sign in to comment.