Skip to content

Commit

Permalink
fix: Keep cookie value in sync when navigating within a locale (#828)
Browse files Browse the repository at this point in the history
Fixes #826
  • Loading branch information
amannn authored Feb 1, 2024
1 parent 65241c1 commit 1167523
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/next-intl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@
},
{
"path": "dist/production/navigation.react-client.js",
"limit": "2.83 KB"
"limit": "2.84 KB"
},
{
"path": "dist/production/navigation.react-server.js",
"limit": "2.94 KB"
"limit": "2.95 KB"
},
{
"path": "dist/production/server.react-client.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function syncLocaleCookie(
locale: string,
nextLocale?: string
) {
const isSwitchingLocale = nextLocale !== locale;
const isSwitchingLocale = nextLocale !== locale && nextLocale != null;

if (
!isSwitchingLocale ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ describe('unprefixed routing', () => {
callRouter((router) => router.push('/about', {locale: 'de'}));
expect(document.cookie).toContain('NEXT_LOCALE=de');

callRouter((router) => router.push('/test'));
expect(document.cookie).toContain('NEXT_LOCALE=de');

callRouter((router) => router.replace('/about', {locale: 'es'}));
expect(document.cookie).toContain('NEXT_LOCALE=es');

Expand Down

0 comments on commit 1167523

Please sign in to comment.