mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor(guide): redirect old urls to /legacy (#11170)
* refactor(guide): redirect old urls to /legacy * chore: suggestion Co-authored-by: Almeida <github@almeidx.dev> --------- Co-authored-by: Almeida <github@almeidx.dev> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -5,12 +5,19 @@ export function middleware(request: NextRequest) {
|
||||
if (request.nextUrl.pathname.startsWith('/guide/')) {
|
||||
const newUrl = request.nextUrl.clone();
|
||||
newUrl.pathname = newUrl.pathname.replace('/guide/', '/');
|
||||
return NextResponse.redirect(new URL(newUrl.pathname, request.url));
|
||||
return NextResponse.redirect(newUrl);
|
||||
}
|
||||
|
||||
return NextResponse.redirect(new URL('/legacy', request.url));
|
||||
// Redirect old urls to /legacy
|
||||
if (!request.nextUrl.pathname.startsWith('/legacy') && !request.nextUrl.pathname.startsWith('/voice')) {
|
||||
const newUrl = request.nextUrl.clone();
|
||||
newUrl.pathname = `/legacy${newUrl.pathname}`;
|
||||
return NextResponse.redirect(newUrl);
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ['/', '/guide/:path*'],
|
||||
matcher: ['/((?!_next|api|og|.*\\..*|_static).*)'],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user