next-intl 4.13.2 → 4.13.3
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.
|
@@ -2,6 +2,21 @@ import { getAcceptLanguageLocale } from './resolveLocale.js';
|
|
|
2
2
|
|
|
3
3
|
function syncCookie(request, response, locale, routing, domain) {
|
|
4
4
|
if (!routing.localeCookie) return;
|
|
5
|
+
|
|
6
|
+
// Only document requests indicate that the user is actually
|
|
7
|
+
// navigating to a page—in contrast to background requests of the
|
|
8
|
+
// client-side router like prefetches and cache revalidations.
|
|
9
|
+
// E.g. as of Next.js 16.3, the router revalidates previously
|
|
10
|
+
// visited routes after a navigation, including routes of a locale
|
|
11
|
+
// the user has just switched away from. Updating the cookie based
|
|
12
|
+
// on such a request would overwrite the locale that was just set
|
|
13
|
+
// when switching the locale. Note that Next.js strips router
|
|
14
|
+
// headers like `Next-Router-Prefetch` before invoking the
|
|
15
|
+
// middleware, therefore `Sec-Fetch-Dest` is used to detect
|
|
16
|
+
// background requests. Locale switches via a soft navigation
|
|
17
|
+
// update the cookie on the client side.
|
|
18
|
+
const secFetchDest = request.headers.get('sec-fetch-dest');
|
|
19
|
+
if (secFetchDest != null && secFetchDest !== 'document') return;
|
|
5
20
|
const {
|
|
6
21
|
name,
|
|
7
22
|
...rest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getAcceptLanguageLocale as e}from"./resolveLocale.js";function o(o,a,l
|
|
1
|
+
import{getAcceptLanguageLocale as e}from"./resolveLocale.js";function o(o,t,s,a,l){if(!a.localeCookie)return;const c=o.headers.get("sec-fetch-dest");if(null!=c&&"document"!==c)return;const{name:i,...r}=a.localeCookie,n=o.cookies.has(i);if(n&&o.cookies.get(i)?.value!==s)t.cookies.set(i,s,{path:o.nextUrl.basePath||void 0,...r});else if(!n){e(o.headers,l?.locales||a.locales,a.defaultLocale)!==s&&t.cookies.set(i,s,{path:o.nextUrl.basePath||void 0,...r})}}export{o as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -127,11 +127,11 @@
|
|
|
127
127
|
"@formatjs/intl-localematcher": "^0.8.1",
|
|
128
128
|
"@parcel/watcher": "^2.4.1",
|
|
129
129
|
"@swc/core": "^1.15.2",
|
|
130
|
-
"icu-minify": "^4.13.
|
|
130
|
+
"icu-minify": "^4.13.3",
|
|
131
131
|
"negotiator": "^1.0.0",
|
|
132
|
-
"next-intl-swc-plugin-extractor": "^4.13.
|
|
132
|
+
"next-intl-swc-plugin-extractor": "^4.13.3",
|
|
133
133
|
"po-parser": "^2.1.1",
|
|
134
|
-
"use-intl": "^4.13.
|
|
134
|
+
"use-intl": "^4.13.3"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
137
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"optional": true
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "89ae78319a4a6da95bdcbb91dc11e9ba56d745ae"
|
|
146
146
|
}
|