next-intl 3.19.2 → 3.19.4
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.
- package/dist/development/middleware/getAlternateLinksHeaderValue.js +1 -1
- package/dist/development/middleware/middleware.js +9 -2
- package/dist/development/middleware/utils.js +7 -4
- package/dist/esm/middleware/getAlternateLinksHeaderValue.js +1 -1
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/production/middleware/getAlternateLinksHeaderValue.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/utils.js +1 -1
- package/dist/types/src/middleware/utils.d.ts +1 -1
- package/package.json +3 -3
|
@@ -39,7 +39,7 @@ function getAlternateLinksHeaderValue(_ref) {
|
|
|
39
39
|
return pathname;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
const links = utils.getLocalePrefixes(routing.locales, routing.localePrefix).flatMap(_ref2 => {
|
|
42
|
+
const links = utils.getLocalePrefixes(routing.locales, routing.localePrefix, false).flatMap(_ref2 => {
|
|
43
43
|
let [locale, prefix] = _ref2;
|
|
44
44
|
function prefixPathname(pathname) {
|
|
45
45
|
if (pathname === '/') {
|
|
@@ -20,8 +20,15 @@ function createMiddleware(routing, options) {
|
|
|
20
20
|
};
|
|
21
21
|
return function middleware(request) {
|
|
22
22
|
var _resolvedRouting$doma;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
let unsafeExternalPathname;
|
|
24
|
+
try {
|
|
25
|
+
// Resolve potential foreign symbols (e.g. /ja/%E7%B4%84 → /ja/約))
|
|
26
|
+
unsafeExternalPathname = decodeURI(request.nextUrl.pathname);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// In case an invalid pathname is encountered, forward
|
|
29
|
+
// it to Next.js which in turn responds with a 400
|
|
30
|
+
return server.NextResponse.next();
|
|
31
|
+
}
|
|
25
32
|
|
|
26
33
|
// Sanitize malicious URIs to prevent open redirect attacks due to
|
|
27
34
|
// decodeURI doesn't escape encoded backslashes ('%5C' & '%5c')
|
|
@@ -79,13 +79,16 @@ function getNormalizedPathname(pathname, locales, localePrefix) {
|
|
|
79
79
|
return result;
|
|
80
80
|
}
|
|
81
81
|
function getLocalePrefixes(locales, localePrefix) {
|
|
82
|
-
|
|
82
|
+
let sort = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
83
|
+
const prefixes = locales.map(locale => [locale, utils.getLocalePrefix(locale, localePrefix)]);
|
|
84
|
+
if (sort) {
|
|
85
|
+
// More specific ones first
|
|
86
|
+
prefixes.sort((a, b) => b[1].length - a[1].length);
|
|
87
|
+
}
|
|
88
|
+
return prefixes;
|
|
83
89
|
}
|
|
84
90
|
function getPathnameMatch(pathname, locales, localePrefix) {
|
|
85
91
|
const localePrefixes = getLocalePrefixes(locales, localePrefix);
|
|
86
|
-
|
|
87
|
-
// More specific ones first
|
|
88
|
-
localePrefixes.sort((a, b) => b[1].length - a[1].length);
|
|
89
92
|
for (const [locale, prefix] of localePrefixes) {
|
|
90
93
|
let exact, matches;
|
|
91
94
|
if (pathname === prefix || pathname.startsWith(prefix + '/')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as o,isLocaleSupportedOnDomain as n,applyBasePath as l,formatTemplatePathname as r}from"./utils.js";function c(c){var m;let{localizedPathnames:p,request:s,resolvedLocale:i,routing:f}=c;const h=s.nextUrl.clone(),u=a(s.headers);function d(a,t){return a.pathname=e(a.pathname),s.nextUrl.basePath&&((a=new URL(a)).pathname=l(a.pathname,s.nextUrl.basePath)),"<".concat(a.toString(),'>; rel="alternate"; hreflang="').concat(t,'"')}function x(e,a){return p&&"object"==typeof p?r(e,p[i],p[a]):e}u&&(h.port="",h.host=u),h.protocol=null!==(m=s.headers.get("x-forwarded-proto"))&&void 0!==m?m:h.protocol,h.pathname=t(h.pathname,f.locales,f.localePrefix);const w=o(f.locales,f.localePrefix).flatMap((e=>{let a,[t,o]=e;function l(e){return"/"===e?o:o+e}if(f.domains){return(f.domains.filter((e=>n(t,e)))||[]).map((e=>(a=new URL(h),a.port="",a.host=e.domain,a.pathname=x(h.pathname,t),t===e.defaultLocale&&"always"!==f.localePrefix.mode||(a.pathname=l(a.pathname)),d(a,t))))}{let e;e=p&&"object"==typeof p?x(h.pathname,t):h.pathname,t===f.defaultLocale&&"always"!==f.localePrefix.mode||(e=l(e)),a=new URL(e,h)}return d(a,t)}));if(!f.domains&&("always"!==f.localePrefix.mode||"/"===h.pathname)){const e=new URL(x(h.pathname,f.defaultLocale),h);w.push(d(e,"x-default"))}return w.join(", ")}export{c as default};
|
|
1
|
+
import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as o,isLocaleSupportedOnDomain as n,applyBasePath as l,formatTemplatePathname as r}from"./utils.js";function c(c){var m;let{localizedPathnames:p,request:s,resolvedLocale:i,routing:f}=c;const h=s.nextUrl.clone(),u=a(s.headers);function d(a,t){return a.pathname=e(a.pathname),s.nextUrl.basePath&&((a=new URL(a)).pathname=l(a.pathname,s.nextUrl.basePath)),"<".concat(a.toString(),'>; rel="alternate"; hreflang="').concat(t,'"')}function x(e,a){return p&&"object"==typeof p?r(e,p[i],p[a]):e}u&&(h.port="",h.host=u),h.protocol=null!==(m=s.headers.get("x-forwarded-proto"))&&void 0!==m?m:h.protocol,h.pathname=t(h.pathname,f.locales,f.localePrefix);const w=o(f.locales,f.localePrefix,!1).flatMap((e=>{let a,[t,o]=e;function l(e){return"/"===e?o:o+e}if(f.domains){return(f.domains.filter((e=>n(t,e)))||[]).map((e=>(a=new URL(h),a.port="",a.host=e.domain,a.pathname=x(h.pathname,t),t===e.defaultLocale&&"always"!==f.localePrefix.mode||(a.pathname=l(a.pathname)),d(a,t))))}{let e;e=p&&"object"==typeof p?x(h.pathname,t):h.pathname,t===f.defaultLocale&&"always"!==f.localePrefix.mode||(e=l(e)),a=new URL(e,h)}return d(a,t)}));if(!f.domains&&("always"!==f.localePrefix.mode||"/"===h.pathname)){const e=new URL(x(h.pathname,f.defaultLocale),h);w.push(d(e,"x-default"))}return w.join(", ")}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as l}from"../routing/config.js";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as t,normalizeTrailingSlash as a,getLocalePrefix as n}from"../shared/utils.js";import r from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import s from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as u,formatPathname as x,getBestMatchingDomain as v,applyBasePath as p,getLocaleAsPrefix as U}from"./utils.js";function P(P,L){var g,k,j,w;const b=l(P),
|
|
1
|
+
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as l}from"../routing/config.js";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as t,normalizeTrailingSlash as a,getLocalePrefix as n}from"../shared/utils.js";import r from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import s from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as u,formatPathname as x,getBestMatchingDomain as v,applyBasePath as p,getLocaleAsPrefix as U}from"./utils.js";function P(P,L){var g,k,j,w;const b=l(P),y={alternateLinks:null===(g=null!==(k=null==L?void 0:L.alternateLinks)&&void 0!==k?k:P.alternateLinks)||void 0===g||g,localeDetection:null===(j=null!==(w=null==L?void 0:L.localeDetection)&&void 0!==w?w:null==P?void 0:P.localeDetection)||void 0===j||j};return function(l){var P;let L;try{L=decodeURI(l.nextUrl.pathname)}catch(l){return e.next()}const g=c(L),{domain:k,locale:j}=i(b,y,l.headers,l.cookies,g),w=k?k.defaultLocale===j:j===b.defaultLocale,D=(null===(P=b.domains)||void 0===P?void 0:P.filter((e=>d(j,e))))||[],R=null!=b.domains&&!k;function q(t){const a=new URL(t,l.url);l.nextUrl.basePath&&(a.pathname=p(a.pathname,l.nextUrl.basePath));const n=new Headers(l.headers);return n.set(o,j),e.rewrite(a,{request:{headers:n}})}function H(o,t){const n=new URL(a(o),l.url);if(D.length>0&&!t){const e=v(k,j,D);e&&(t=e.domain,e.defaultLocale===j&&"as-needed"===b.localePrefix.mode&&(n.pathname=f(n.pathname,b.locales,b.localePrefix)))}var r,i;t&&(n.host=t,l.headers.get("x-forwarded-host")&&(n.protocol=null!==(r=l.headers.get("x-forwarded-proto"))&&void 0!==r?r:l.nextUrl.protocol,n.port=null!==(i=l.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return l.nextUrl.basePath&&(n.pathname=p(n.pathname,l.nextUrl.basePath)),e.redirect(n.toString())}const z=f(g,b.locales,b.localePrefix),A=m(g,b.locales,b.localePrefix),C=null!=A,I="never"===b.localePrefix.mode||w&&"as-needed"===b.localePrefix.mode;let S,V,B=z;if("pathnames"in b){let e;if([e,V]=h(b.pathnames,z,j),V){const o=b.pathnames[V],a="string"==typeof o?o:o[j];if(t(a,z))B=u(z,a,V);else{let t;t=e?"string"==typeof o?o:o[e]:V;const r=I?void 0:n(j,b.localePrefix),i=u(z,t,a);S=H(x(i,r,l.nextUrl.search))}}}if(!S)if("/"!==B||C){const e=x(B,U(j),l.nextUrl.search);if(C){const o=x(z,A.prefix,l.nextUrl.search);if("never"===b.localePrefix.mode)S=H(x(z,void 0,l.nextUrl.search));else if(A.exact)if(w&&I)S=H(x(z,void 0,l.nextUrl.search));else if(b.domains){const l=v(k,A.locale,D);S=(null==k?void 0:k.domain)===(null==l?void 0:l.domain)||R?q(e):H(o,null==l?void 0:l.domain)}else S=q(e);else S=H(o)}else S=I?q(e):H(x(z,n(j,b.localePrefix),l.nextUrl.search))}else S=I?q(x(B,U(j),l.nextUrl.search)):H(x(z,n(j,b.localePrefix),l.nextUrl.search));var E;(y.localeDetection&&s(l,S,j),"never"!==b.localePrefix.mode&&y.alternateLinks&&b.locales.length>1)&&S.headers.set("Link",r({routing:b,localizedPathnames:null!=V&&"pathnames"in b?null===(E=b.pathnames)||void 0===E?void 0:E[V]:void 0,request:l,resolvedLocale:j}));return S}}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSortedPathnames as e,matchesPathname as t,normalizeTrailingSlash as n,getLocalePrefix as
|
|
1
|
+
import{getSortedPathnames as e,matchesPathname as t,normalizeTrailingSlash as n,getLocalePrefix as o,templateToRegex as r,prefixPathname as c}from"../shared/utils.js";function l(n,o,r){const c=e(Object.keys(n));for(const e of c){const c=n[e];if("string"==typeof c){if(t(c,o))return[void 0,e]}else{const n=Object.entries(c),l=n.findIndex((e=>{let[t]=e;return t===r}));l>0&&n.unshift(n.splice(l,1)[0]);for(const[r,c]of n)if(t(c,o))return[r,e]}}for(const e of Object.keys(n))if(t(e,o))return[void 0,e];return[void 0,void 0]}function i(e,t,o,r){let c="";return c+=d(o,a(t,e)),c=n(c),c}function u(e,t,o){e.endsWith("/")||(e+="/");const r=s(t,o),c=new RegExp("^(".concat(r.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),l=e.match(c);let i=l?"/"+l[2]:e;return"/"!==i&&(i=n(i)),i}function s(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const r=e.map((e=>[e,o(e,t)]));return n&&r.sort(((e,t)=>t[1].length-e[1].length)),r}function f(e,t,n){const o=s(t,n);for(const[t,n]of o){let o,r;if(e===n||e.startsWith(n+"/"))o=r=!0;else{const t=e.toLowerCase(),c=n.toLowerCase();(t===c||t.startsWith(c+"/"))&&(o=!1,r=!0)}if(r)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:o}}}function a(e,t){const o=n(t),c=n(e),l=r(c).exec(o);if(!l)return;const i={};for(let e=1;e<l.length;e++){var u;const t=null===(u=c.match(/\[([^\]]+)\]/g))||void 0===u?void 0:u[e-1].replace(/[[\]]/g,"");t&&(i[t]=l[e])}return i}function d(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((e=>{let[t,o]=e;n=n.replace("[".concat(t,"]"),o)})),n}function h(e,t,n){let o=e;return t&&(o=c(t,o)),n&&(o+=n),o}function g(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0}function p(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function v(e,t,n){let o;return e&&p(t,e)&&(o=e),o||(o=n.find((e=>e.defaultLocale===t))),o||(o=n.find((e=>null!=e.locales&&e.locales.includes(t)))),o||null!=(null==e?void 0:e.locales)||(o=e),o||(o=n.find((e=>!e.locales))),o}function x(e,t){return n(t+e)}function m(e){return"/".concat(e)}function j(e){return e.replace(/\\/g,"%5C").replace(/\/+/g,"/")}export{x as applyBasePath,h as formatPathname,d as formatPathnameTemplate,i as formatTemplatePathname,v as getBestMatchingDomain,g as getHost,l as getInternalTemplate,m as getLocaleAsPrefix,s as getLocalePrefixes,u as getNormalizedPathname,f as getPathnameMatch,a as getRouteParams,p as isLocaleSupportedOnDomain,j as sanitizePathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js"),a=require("./utils.js");exports.default=function(t){var o;let{localizedPathnames:n,request:l,resolvedLocale:r,routing:s}=t;const i=l.nextUrl.clone(),c=a.getHost(l.headers);function p(t,o){return t.pathname=e.normalizeTrailingSlash(t.pathname),l.nextUrl.basePath&&((t=new URL(t)).pathname=a.applyBasePath(t.pathname,l.nextUrl.basePath)),"<".concat(t.toString(),'>; rel="alternate"; hreflang="').concat(o,'"')}function m(e,t){return n&&"object"==typeof n?a.formatTemplatePathname(e,n[r],n[t]):e}c&&(i.port="",i.host=c),i.protocol=null!==(o=l.headers.get("x-forwarded-proto"))&&void 0!==o?o:i.protocol,i.pathname=a.getNormalizedPathname(i.pathname,s.locales,s.localePrefix);const h=a.getLocalePrefixes(s.locales,s.localePrefix).flatMap((e=>{let t,[o,l]=e;function r(e){return"/"===e?l:l+e}if(s.domains){return(s.domains.filter((e=>a.isLocaleSupportedOnDomain(o,e)))||[]).map((e=>(t=new URL(i),t.port="",t.host=e.domain,t.pathname=m(i.pathname,o),o===e.defaultLocale&&"always"!==s.localePrefix.mode||(t.pathname=r(t.pathname)),p(t,o))))}{let e;e=n&&"object"==typeof n?m(i.pathname,o):i.pathname,o===s.defaultLocale&&"always"!==s.localePrefix.mode||(e=r(e)),t=new URL(e,i)}return p(t,o)}));if(!s.domains&&("always"!==s.localePrefix.mode||"/"===i.pathname)){const e=new URL(m(i.pathname,s.defaultLocale),i);h.push(p(e,"x-default"))}return h.join(", ")};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js"),a=require("./utils.js");exports.default=function(t){var o;let{localizedPathnames:n,request:l,resolvedLocale:r,routing:s}=t;const i=l.nextUrl.clone(),c=a.getHost(l.headers);function p(t,o){return t.pathname=e.normalizeTrailingSlash(t.pathname),l.nextUrl.basePath&&((t=new URL(t)).pathname=a.applyBasePath(t.pathname,l.nextUrl.basePath)),"<".concat(t.toString(),'>; rel="alternate"; hreflang="').concat(o,'"')}function m(e,t){return n&&"object"==typeof n?a.formatTemplatePathname(e,n[r],n[t]):e}c&&(i.port="",i.host=c),i.protocol=null!==(o=l.headers.get("x-forwarded-proto"))&&void 0!==o?o:i.protocol,i.pathname=a.getNormalizedPathname(i.pathname,s.locales,s.localePrefix);const h=a.getLocalePrefixes(s.locales,s.localePrefix,!1).flatMap((e=>{let t,[o,l]=e;function r(e){return"/"===e?l:l+e}if(s.domains){return(s.domains.filter((e=>a.isLocaleSupportedOnDomain(o,e)))||[]).map((e=>(t=new URL(i),t.port="",t.host=e.domain,t.pathname=m(i.pathname,o),o===e.defaultLocale&&"always"!==s.localePrefix.mode||(t.pathname=r(t.pathname)),p(t,o))))}{let e;e=n&&"object"==typeof n?m(i.pathname,o):i.pathname,o===s.defaultLocale&&"always"!==s.localePrefix.mode||(e=r(e)),t=new URL(e,i)}return p(t,o)}));if(!s.domains&&("always"!==s.localePrefix.mode||"/"===i.pathname)){const e=new URL(m(i.pathname,s.defaultLocale),i);h.push(p(e,"x-default"))}return h.join(", ")};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../routing/config.js"),t=require("../shared/constants.js"),l=require("../shared/utils.js"),n=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),r=require("./syncCookie.js"),i=require("./utils.js");exports.default=function(s,c){var d,m,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../routing/config.js"),t=require("../shared/constants.js"),l=require("../shared/utils.js"),n=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),r=require("./syncCookie.js"),i=require("./utils.js");exports.default=function(s,c){var d,h,m,f;const u=a.receiveRoutingConfig(s),x={alternateLinks:null===(d=null!==(h=null==c?void 0:c.alternateLinks)&&void 0!==h?h:s.alternateLinks)||void 0===d||d,localeDetection:null===(m=null!==(f=null==c?void 0:c.localeDetection)&&void 0!==f?f:null==s?void 0:s.localeDetection)||void 0===m||m};return function(a){var s;let c;try{c=decodeURI(a.nextUrl.pathname)}catch(a){return e.NextResponse.next()}const d=i.sanitizePathname(c),{domain:h,locale:m}=o.default(u,x,a.headers,a.cookies,d),f=h?h.defaultLocale===m:m===u.defaultLocale,P=(null===(s=u.domains)||void 0===s?void 0:s.filter((e=>i.isLocaleSupportedOnDomain(m,e))))||[],p=null!=u.domains&&!h;function v(l){const n=new URL(l,a.url);a.nextUrl.basePath&&(n.pathname=i.applyBasePath(n.pathname,a.nextUrl.basePath));const o=new Headers(a.headers);return o.set(t.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(n,{request:{headers:o}})}function g(t,n){const o=new URL(l.normalizeTrailingSlash(t),a.url);if(P.length>0&&!n){const e=i.getBestMatchingDomain(h,m,P);e&&(n=e.domain,e.defaultLocale===m&&"as-needed"===u.localePrefix.mode&&(o.pathname=i.getNormalizedPathname(o.pathname,u.locales,u.localePrefix)))}var r,s;n&&(o.host=n,a.headers.get("x-forwarded-host")&&(o.protocol=null!==(r=a.headers.get("x-forwarded-proto"))&&void 0!==r?r:a.nextUrl.protocol,o.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(o.pathname=i.applyBasePath(o.pathname,a.nextUrl.basePath)),e.NextResponse.redirect(o.toString())}const L=i.getNormalizedPathname(d,u.locales,u.localePrefix),U=i.getPathnameMatch(d,u.locales,u.localePrefix),q=null!=U,j="never"===u.localePrefix.mode||f&&"as-needed"===u.localePrefix.mode;let k,D,R=L;if("pathnames"in u){let e;if([e,D]=i.getInternalTemplate(u.pathnames,L,m),D){const t=u.pathnames[D],n="string"==typeof t?t:t[m];if(l.matchesPathname(n,L))R=i.formatTemplatePathname(L,n,D);else{let o;o=e?"string"==typeof t?t:t[e]:D;const r=j?void 0:l.getLocalePrefix(m,u.localePrefix),s=i.formatTemplatePathname(L,o,n);k=g(i.formatPathname(s,r,a.nextUrl.search))}}}if(!k)if("/"!==R||q){const e=i.formatPathname(R,i.getLocaleAsPrefix(m),a.nextUrl.search);if(q){const t=i.formatPathname(L,U.prefix,a.nextUrl.search);if("never"===u.localePrefix.mode)k=g(i.formatPathname(L,void 0,a.nextUrl.search));else if(U.exact)if(f&&j)k=g(i.formatPathname(L,void 0,a.nextUrl.search));else if(u.domains){const a=i.getBestMatchingDomain(h,U.locale,P);k=(null==h?void 0:h.domain)===(null==a?void 0:a.domain)||p?v(e):g(t,null==a?void 0:a.domain)}else k=v(e);else k=g(t)}else k=j?v(e):g(i.formatPathname(L,l.getLocalePrefix(m,u.localePrefix),a.nextUrl.search))}else k=j?v(i.formatPathname(R,i.getLocaleAsPrefix(m),a.nextUrl.search)):g(i.formatPathname(L,l.getLocalePrefix(m,u.localePrefix),a.nextUrl.search));var w;(x.localeDetection&&r.default(a,k,m),"never"!==u.localePrefix.mode&&x.alternateLinks&&u.locales.length>1)&&k.headers.set("Link",n.default({routing:u,localizedPathnames:null!=D&&"pathnames"in u?null===(w=u.pathnames)||void 0===w?void 0:w[D]:void 0,request:a,resolvedLocale:m}));return k}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(t,n){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(t,n){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const o=t.map((t=>[t,e.getLocalePrefix(t,n)]));return r&&o.sort(((e,t)=>t[1].length-e[1].length)),o}function n(t,n){const r=e.normalizeTrailingSlash(n),o=e.normalizeTrailingSlash(t),a=e.templateToRegex(o).exec(r);if(!a)return;const l={};for(let e=1;e<a.length;e++){var i;const t=null===(i=o.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[e-1].replace(/[[\]]/g,"");t&&(l[t]=a[e])}return l}function r(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((e=>{let[t,r]=e;n=n.replace("[".concat(t,"]"),r)})),n}function o(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}exports.applyBasePath=function(t,n){return e.normalizeTrailingSlash(n+t)},exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=r,exports.formatTemplatePathname=function(t,o,a,l){let i="";return i+=r(a,n(o,t)),i=e.normalizeTrailingSlash(i),i},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&o(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>null!=e.locales&&e.locales.includes(t)))),r||null!=(null==e?void 0:e.locales)||(r=e),r||(r=n.find((e=>!e.locales))),r},exports.getHost=function(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0},exports.getInternalTemplate=function(t,n,r){const o=e.getSortedPathnames(Object.keys(t));for(const a of o){const o=t[a];if("string"==typeof o){const t=o;if(e.matchesPathname(t,n))return[void 0,a]}else{const t=Object.entries(o),l=t.findIndex((e=>{let[t]=e;return t===r}));l>0&&t.unshift(t.splice(l,1)[0]);for(const[r,o]of t)if(e.matchesPathname(o,n))return[r,a]}}for(const r of Object.keys(t))if(e.matchesPathname(r,n))return[void 0,r];return[void 0,void 0]},exports.getLocaleAsPrefix=function(e){return"/".concat(e)},exports.getLocalePrefixes=t,exports.getNormalizedPathname=function(n,r,o){n.endsWith("/")||(n+="/");const a=t(r,o),l=new RegExp("^(".concat(a.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),i=n.match(l);let s=i?"/"+i[2]:n;return"/"!==s&&(s=e.normalizeTrailingSlash(s)),s},exports.getPathnameMatch=function(e,n,r){const o=t(n,r);for(const[t,n]of o){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),a=n.toLowerCase();(t===a||t.startsWith(a+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}},exports.getRouteParams=n,exports.isLocaleSupportedOnDomain=o,exports.sanitizePathname=function(e){return e.replace(/\\/g,"%5C").replace(/\/+/g,"/")};
|
|
@@ -7,7 +7,7 @@ export declare function formatTemplatePathname(sourcePathname: string, sourceTem
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function getNormalizedPathname<AppLocales extends Locales>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales>): string;
|
|
9
9
|
export declare function findCaseInsensitiveString(candidate: string, strings: Array<string>): string | undefined;
|
|
10
|
-
export declare function getLocalePrefixes<AppLocales extends Locales>(locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales
|
|
10
|
+
export declare function getLocalePrefixes<AppLocales extends Locales>(locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales>, sort?: boolean): Array<[AppLocales[number], string]>;
|
|
11
11
|
export declare function getPathnameMatch<AppLocales extends Locales>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales>): {
|
|
12
12
|
locale: AppLocales[number];
|
|
13
13
|
prefix: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
89
89
|
"negotiator": "^0.6.3",
|
|
90
|
-
"use-intl": "^3.19.
|
|
90
|
+
"use-intl": "^3.19.4"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
94
94
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "4c9c1307515618353a9669aafe25508306fe6fcd"
|
|
97
97
|
}
|