Skip to content

Commit

Permalink
fix(next-international): rewrite strategies keep search params (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiiBz authored Oct 15, 2023
1 parent 410d1b5 commit a6dc753
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/next-international/src/app/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ export function createI18nMiddleware<const Locales extends readonly string[]>(co
) {
const pathnameWithoutLocale = request.nextUrl.pathname.slice(requestLocale.length + 1);
const newUrl = new URL(pathnameWithoutLocale === '' ? '/' : pathnameWithoutLocale, request.url);
newUrl.search = request.nextUrl.search;
response = NextResponse.redirect(newUrl);
}

if (config.urlMappingStrategy === 'rewriteDefault' && requestLocale === config.defaultLocale) {
const pathnameWithoutLocale = request.nextUrl.pathname.slice(requestLocale.length + 1);
const newUrl = new URL(pathnameWithoutLocale === '' ? '/' : pathnameWithoutLocale, request.url);
newUrl.search = request.nextUrl.search;
response = NextResponse.redirect(newUrl);
}

Expand Down

0 comments on commit a6dc753

Please sign in to comment.