next-intl 4.5.6 → 4.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,14 +6,21 @@ function syncCookie(request, response, locale, routing, domain) {
6
6
  name,
7
7
  ...rest
8
8
  } = routing.localeCookie;
9
- const acceptLanguageLocale = getAcceptLanguageLocale(request.headers, domain?.locales || routing.locales, routing.defaultLocale);
10
9
  const hasLocaleCookie = request.cookies.has(name);
11
10
  const hasOutdatedCookie = hasLocaleCookie && request.cookies.get(name)?.value !== locale;
12
- if (hasLocaleCookie ? hasOutdatedCookie : acceptLanguageLocale !== locale) {
11
+ if (hasOutdatedCookie) {
13
12
  response.cookies.set(name, locale, {
14
13
  path: request.nextUrl.basePath || undefined,
15
14
  ...rest
16
15
  });
16
+ } else if (!hasLocaleCookie) {
17
+ const acceptLanguageLocale = getAcceptLanguageLocale(request.headers, domain?.locales || routing.locales, routing.defaultLocale);
18
+ if (acceptLanguageLocale !== locale) {
19
+ response.cookies.set(name, locale, {
20
+ path: request.nextUrl.basePath || undefined,
21
+ ...rest
22
+ });
23
+ }
17
24
  }
18
25
  }
19
26
 
@@ -1 +1 @@
1
- import{getAcceptLanguageLocale as e}from"./resolveLocale.js";function o(o,a,l,s,t){if(!s.localeCookie)return;const{name:c,...i}=s.localeCookie,r=e(o.headers,t?.locales||s.locales,s.defaultLocale),n=o.cookies.has(c),f=n&&o.cookies.get(c)?.value!==l;(n?f:r!==l)&&a.cookies.set(c,l,{path:o.nextUrl.basePath||void 0,...i})}export{o as default};
1
+ import{getAcceptLanguageLocale as e}from"./resolveLocale.js";function o(o,a,l,s,t){if(!s.localeCookie)return;const{name:i,...c}=s.localeCookie,r=o.cookies.has(i);if(r&&o.cookies.get(i)?.value!==l)a.cookies.set(i,l,{path:o.nextUrl.basePath||void 0,...c});else if(!r){e(o.headers,t?.locales||s.locales,s.defaultLocale)!==l&&a.cookies.set(i,l,{path:o.nextUrl.basePath||void 0,...c})}}export{o as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "4.5.6",
3
+ "version": "4.5.7",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "funding": [
@@ -127,9 +127,9 @@
127
127
  "@formatjs/intl-localematcher": "^0.5.4",
128
128
  "@swc/core": "^1.15.2",
129
129
  "negotiator": "^1.0.0",
130
- "next-intl-swc-plugin-extractor": "^4.5.6",
130
+ "next-intl-swc-plugin-extractor": "^4.5.7",
131
131
  "po-parser": "^1.0.2",
132
- "use-intl": "^4.5.6"
132
+ "use-intl": "^4.5.7"
133
133
  },
134
134
  "peerDependencies": {
135
135
  "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
@@ -141,5 +141,5 @@
141
141
  "optional": true
142
142
  }
143
143
  },
144
- "gitHead": "812d5e73688cebd1d1377a727dd2208796bcb670"
144
+ "gitHead": "2ccc147b68227b32ea451935718c3eb5e73d6e2f"
145
145
  }