next-intl 3.17.1 → 3.17.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.
- package/dist/development/middleware/middleware.js +5 -1
- package/dist/development/middleware/utils.js +7 -0
- package/dist/development/navigation/shared/utils.js +10 -2
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/esm/navigation/shared/utils.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/utils.js +1 -1
- package/dist/production/navigation/shared/utils.js +1 -1
- package/dist/types/src/middleware/utils.d.ts +1 -0
- package/package.json +6 -6
|
@@ -16,7 +16,11 @@ function createMiddleware(input) {
|
|
|
16
16
|
return function middleware(request) {
|
|
17
17
|
var _config$domains;
|
|
18
18
|
// Resolve potential foreign symbols (e.g. /ja/%E7%B4%84 → /ja/約))
|
|
19
|
-
const
|
|
19
|
+
const unsafeExternalPathname = decodeURI(request.nextUrl.pathname);
|
|
20
|
+
|
|
21
|
+
// Sanitize malicious URIs to prevent open redirect attacks due to
|
|
22
|
+
// decodeURI doesn't escape encoded backslashes ('%5C' & '%5c')
|
|
23
|
+
const externalPathname = utils.sanitizePathname(unsafeExternalPathname);
|
|
20
24
|
const {
|
|
21
25
|
domain,
|
|
22
26
|
locale
|
|
@@ -184,6 +184,12 @@ function applyBasePath(pathname, basePath) {
|
|
|
184
184
|
function getLocaleAsPrefix(locale) {
|
|
185
185
|
return "/".concat(locale);
|
|
186
186
|
}
|
|
187
|
+
function sanitizePathname(pathname) {
|
|
188
|
+
// Sanitize malicious URIs, e.g.:
|
|
189
|
+
// '/en/\\example.org → /en/%5C%5Cexample.org'
|
|
190
|
+
// '/en////example.org → /en/example.org'
|
|
191
|
+
return pathname.replace(/\\/g, '%5C').replace(/\/+/g, '/');
|
|
192
|
+
}
|
|
187
193
|
|
|
188
194
|
exports.applyBasePath = applyBasePath;
|
|
189
195
|
exports.formatPathname = formatPathname;
|
|
@@ -198,3 +204,4 @@ exports.getNormalizedPathname = getNormalizedPathname;
|
|
|
198
204
|
exports.getPathnameMatch = getPathnameMatch;
|
|
199
205
|
exports.getRouteParams = getRouteParams;
|
|
200
206
|
exports.isLocaleSupportedOnDomain = isLocaleSupportedOnDomain;
|
|
207
|
+
exports.sanitizePathname = sanitizePathname;
|
|
@@ -50,13 +50,21 @@ function compileLocalizedPathname(_ref) {
|
|
|
50
50
|
if (params) {
|
|
51
51
|
Object.entries(params).forEach(_ref2 => {
|
|
52
52
|
let [key, value] = _ref2;
|
|
53
|
+
let regexp, replacer;
|
|
53
54
|
if (Array.isArray(value)) {
|
|
54
|
-
|
|
55
|
+
regexp = "(\\[)?\\[...".concat(key, "\\](\\])?");
|
|
56
|
+
replacer = value.map(v => String(v)).join('/');
|
|
55
57
|
} else {
|
|
56
|
-
|
|
58
|
+
regexp = "\\[".concat(key, "\\]");
|
|
59
|
+
replacer = String(value);
|
|
57
60
|
}
|
|
61
|
+
compiled = compiled.replace(new RegExp(regexp, 'g'), replacer);
|
|
58
62
|
});
|
|
59
63
|
}
|
|
64
|
+
|
|
65
|
+
// Clean up optional catch-all segments that were not replaced
|
|
66
|
+
compiled = compiled.replace(/\[\[\.\.\..+\]\]/g, '');
|
|
67
|
+
compiled = utils.normalizeTrailingSlash(compiled);
|
|
60
68
|
if (compiled.includes('[')) {
|
|
61
69
|
// Next.js throws anyway, therefore better provide a more helpful error message
|
|
62
70
|
throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(template, "\nParams: ").concat(JSON.stringify(params)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,normalizeTrailingSlash as r,getLocalePrefix as t}from"../shared/utils.js";import{receiveConfig as a}from"./config.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{
|
|
1
|
+
import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,normalizeTrailingSlash as r,getLocalePrefix as t}from"../shared/utils.js";import{receiveConfig as a}from"./config.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as x,formatPathname as u,getBestMatchingDomain as p,applyBasePath as v,getLocaleAsPrefix as U}from"./utils.js";function P(P){const g=a(P);return function(a){var P;const L=decodeURI(a.nextUrl.pathname),j=c(L),{domain:w,locale:k}=s(g,a.headers,a.cookies,j),b=w?w.defaultLocale===k:k===g.defaultLocale,y=(null===(P=g.domains)||void 0===P?void 0:P.filter((e=>d(k,e))))||[],R=null!=g.domains&&!w;function q(l){const r=new URL(l,a.url);a.nextUrl.basePath&&(r.pathname=v(r.pathname,a.nextUrl.basePath));const t=new Headers(a.headers);return t.set(o,k),e.rewrite(r,{request:{headers:t}})}function H(o,l){const t=new URL(r(o),a.url);if(y.length>0&&!l){const e=p(w,k,y);e&&(l=e.domain,e.defaultLocale===k&&"as-needed"===g.localePrefix.mode&&(t.pathname=f(t.pathname,g.locales,g.localePrefix)))}var n,s;l&&(t.host=l,a.headers.get("x-forwarded-host")&&(t.protocol=null!==(n=a.headers.get("x-forwarded-proto"))&&void 0!==n?n:a.nextUrl.protocol,t.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(t.pathname=v(t.pathname,a.nextUrl.basePath)),e.redirect(t.toString())}const z=f(j,g.locales,g.localePrefix),A=m(j,g.locales,g.localePrefix),C=null!=A,D="never"===g.localePrefix.mode||b&&"as-needed"===g.localePrefix.mode;let I,S,V=z;if(g.pathnames){let e;if([e,S]=h(g.pathnames,z,k),S){const o=g.pathnames[S],r="string"==typeof o?o:o[k];if(l(r,z))V=x(z,r,S);else{let l;l=e?"string"==typeof o?o:o[e]:S;const n=D?void 0:t(k,g.localePrefix),s=x(z,l,r);I=H(u(s,n,a.nextUrl.search))}}}if(!I)if("/"!==V||C){const e=u(V,U(k),a.nextUrl.search);if(C){const o=u(z,A.prefix,a.nextUrl.search);if("never"===g.localePrefix.mode)I=H(u(z,void 0,a.nextUrl.search));else if(A.exact)if(b&&D)I=H(u(z,void 0,a.nextUrl.search));else if(g.domains){const l=p(w,A.locale,y);I=(null==w?void 0:w.domain)===(null==l?void 0:l.domain)||R?q(e):H(o,null==l?void 0:l.domain)}else I=q(e);else I=H(o)}else I=D?q(e):H(u(z,t(k,g.localePrefix),a.nextUrl.search))}else I=D?q(u(V,U(k),a.nextUrl.search)):H(u(z,t(k,g.localePrefix),a.nextUrl.search));var B;(g.localeDetection&&i(a,I,k),"never"!==g.localePrefix.mode&&g.alternateLinks&&g.locales.length>1)&&I.headers.set("Link",n({config:g,localizedPathnames:null!=S?null===(B=g.pathnames)||void 0===B?void 0:B[S]:void 0,request:a,resolvedLocale:k}));return I}}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSortedPathnames as
|
|
1
|
+
import{getSortedPathnames as e,matchesPathname as t,normalizeTrailingSlash as n,getLocalePrefix as r,templateToRegex as o,prefixPathname as c}from"../shared/utils.js";function l(n,r,o){const c=e(Object.keys(n));for(const e of c){const c=n[e];if("string"==typeof c){if(t(c,r))return[void 0,e]}else{const n=Object.entries(c),l=n.findIndex((e=>{let[t]=e;return t===o}));l>0&&n.unshift(n.splice(l,1)[0]);for(const[o,c]of n)if(t(c,r))return[o,e]}}for(const e of Object.keys(n))if(t(e,r))return[void 0,e];return[void 0,void 0]}function i(e,t,r,o){let c="";return c+=d(r,a(t,e)),c=n(c),c}function u(e,t,r){e.endsWith("/")||(e+="/");const o=f(t,r),c=new RegExp("^(".concat(o.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 f(e,t){return e.map((e=>[e,r(e,t)]))}function s(e,t,n){const r=f(t,n);for(const[t,n]of r){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),c=n.toLowerCase();(t===c||t.startsWith(c+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}}function a(e,t){const r=n(t),c=n(e),l=o(c).exec(r);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,r]=e;n=n.replace("[".concat(t,"]"),r)})),n}function p(e,t,n){let r=e;return t&&(r=c(t,r)),n&&(r+=n),r}function h(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 g(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function v(e,t,n){let r;return e&&g(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}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,p as formatPathname,d as formatPathnameTemplate,i as formatTemplatePathname,v as getBestMatchingDomain,h as getHost,l as getInternalTemplate,m as getLocaleAsPrefix,f as getLocalePrefixes,u as getNormalizedPathname,s as getPathnameMatch,a as getRouteParams,g as isLocaleSupportedOnDomain,j as sanitizePathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSortedPathnames as t,matchesPathname as n}from"../../shared/utils.js";function
|
|
1
|
+
import{getSortedPathnames as t,matchesPathname as n,normalizeTrailingSlash as r}from"../../shared/utils.js";function e(t){return"string"==typeof t?{pathname:t}:t}function o(t){function n(t){return String(t)}const r=new URLSearchParams;for(const[e,o]of Object.entries(t))Array.isArray(o)?o.forEach((t=>{r.append(e,n(t))})):r.set(e,n(o));return"?"+r.toString()}function a(t){let{pathname:n,locale:e,params:a,pathnames:c,query:i}=t;function s(t){let n=c[t];return n||(n=t),n}function f(t){const n="string"==typeof t?t:t[e];let c=n;if(a&&Object.entries(a).forEach((t=>{let n,r,[e,o]=t;Array.isArray(o)?(n="(\\[)?\\[...".concat(e,"\\](\\])?"),r=o.map((t=>String(t))).join("/")):(n="\\[".concat(e,"\\]"),r=String(o)),c=c.replace(new RegExp(n,"g"),r)})),c=c.replace(/\[\[\.\.\..+\]\]/g,""),c=r(c),c.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(a)));return i&&(c+=o(i)),c}if("string"==typeof n){return f(s(n))}{const{pathname:t,...r}=n;return{...r,pathname:f(s(t))}}}function c(r,e,o){const a=t(Object.keys(o)),c=decodeURI(e);for(const t of a){const e=o[t];if("string"==typeof e){if(n(e,c))return t}else if(n(e[r],c))return t}return e}function i(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===t?n:n.replace(t,"")}export{a as compileLocalizedPathname,i as getBasePath,c as getRoute,e as normalizeNameOrNameWithParams,o as serializeSearchParams};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),{domain:f,locale:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),m=s.sanitizePathname(d),{domain:f,locale:h}=o.default(c,r.headers,r.cookies,m),u=f?f.defaultLocale===h:h===c.defaultLocale,x=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(h,e))))||[],P=null!=c.domains&&!f;function p(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,h),e.NextResponse.rewrite(l,{request:{headers:o}})}function g(a,l){const o=new URL(t.normalizeTrailingSlash(a),r.url);if(x.length>0&&!l){const e=s.getBestMatchingDomain(f,h,x);e&&(l=e.domain,e.defaultLocale===h&&"as-needed"===c.localePrefix.mode&&(o.pathname=s.getNormalizedPathname(o.pathname,c.locales,c.localePrefix)))}var n,i;l&&(o.host=l,r.headers.get("x-forwarded-host")&&(o.protocol=null!==(n=r.headers.get("x-forwarded-proto"))&&void 0!==n?n:r.nextUrl.protocol,o.port=null!==(i=r.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return r.nextUrl.basePath&&(o.pathname=s.applyBasePath(o.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(o.toString())}const v=s.getNormalizedPathname(m,c.locales,c.localePrefix),L=s.getPathnameMatch(m,c.locales,c.localePrefix),U=null!=L,q="never"===c.localePrefix.mode||u&&"as-needed"===c.localePrefix.mode;let j,w,y=v;if(c.pathnames){let e;if([e,w]=s.getInternalTemplate(c.pathnames,v,h),w){const a=c.pathnames[w],l="string"==typeof a?a:a[h];if(t.matchesPathname(l,v))y=s.formatTemplatePathname(v,l,w);else{let o;o=e?"string"==typeof a?a:a[e]:w;const n=q?void 0:t.getLocalePrefix(h,c.localePrefix),i=s.formatTemplatePathname(v,o,l);j=g(s.formatPathname(i,n,r.nextUrl.search))}}}if(!j)if("/"!==y||U){const e=s.formatPathname(y,s.getLocaleAsPrefix(h),r.nextUrl.search);if(U){const a=s.formatPathname(v,L.prefix,r.nextUrl.search);if("never"===c.localePrefix.mode)j=g(s.formatPathname(v,void 0,r.nextUrl.search));else if(L.exact)if(u&&q)j=g(s.formatPathname(v,void 0,r.nextUrl.search));else if(c.domains){const t=s.getBestMatchingDomain(f,L.locale,x);j=(null==f?void 0:f.domain)===(null==t?void 0:t.domain)||P?p(e):g(a,null==t?void 0:t.domain)}else j=p(e);else j=g(a)}else j=q?p(e):g(s.formatPathname(v,t.getLocalePrefix(h,c.localePrefix),r.nextUrl.search))}else j=q?p(s.formatPathname(y,s.getLocaleAsPrefix(h),r.nextUrl.search)):g(s.formatPathname(v,t.getLocalePrefix(h,c.localePrefix),r.nextUrl.search));var A;(c.localeDetection&&n.default(r,j,h),"never"!==c.localePrefix.mode&&c.alternateLinks&&c.locales.length>1)&&j.headers.set("Link",l.default({config:c,localizedPathnames:null!=w?null===(A=c.pathnames)||void 0===A?void 0:A[w]:void 0,request:r,resolvedLocale:h}));return j}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}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,"/")};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[n,a]of Object.entries(e))Array.isArray(a)?a.forEach((e=>{r.append(n,t(e))})):r.set(n,t(a));return"?"+r.toString()}exports.compileLocalizedPathname=function(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[n,a]of Object.entries(e))Array.isArray(a)?a.forEach((e=>{r.append(n,t(e))})):r.set(n,t(a));return"?"+r.toString()}exports.compileLocalizedPathname=function(r){let{pathname:n,locale:a,params:o,pathnames:i,query:s}=r;function c(e){let t=i[e];return t||(t=e),t}function p(r){let n="string"==typeof r?r:r[a];return o&&Object.entries(o).forEach((e=>{let t,r,[a,o]=e;Array.isArray(o)?(t="(\\[)?\\[...".concat(a,"\\](\\])?"),r=o.map((e=>String(e))).join("/")):(t="\\[".concat(a,"\\]"),r=String(o)),n=n.replace(new RegExp(t,"g"),r)})),n=n.replace(/\[\[\.\.\..+\]\]/g,""),n=e.normalizeTrailingSlash(n),s&&(n+=t(s)),n}if("string"==typeof n){return p(c(n))}{const{pathname:e,...t}=n;return{...t,pathname:p(c(e))}}},exports.getBasePath=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===e?t:t.replace(e,"")},exports.getRoute=function(t,r,n){const a=e.getSortedPathnames(Object.keys(n)),o=decodeURI(r);for(const r of a){const a=n[r];if("string"==typeof a){const t=a;if(e.matchesPathname(t,o))return r}else if(e.matchesPathname(a[t],o))return r}return r},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
|
|
@@ -22,3 +22,4 @@ export declare function isLocaleSupportedOnDomain<AppLocales extends Locales>(lo
|
|
|
22
22
|
export declare function getBestMatchingDomain<AppLocales extends Locales>(curHostDomain: DomainConfig<AppLocales> | undefined, locale: string, domainsConfig: DomainsConfig<AppLocales>): DomainConfig<AppLocales> | undefined;
|
|
23
23
|
export declare function applyBasePath(pathname: string, basePath: string): string;
|
|
24
24
|
export declare function getLocaleAsPrefix<AppLocales extends Locales>(locale: AppLocales[number]): string;
|
|
25
|
+
export declare function sanitizePathname(pathname: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
89
89
|
"negotiator": "^0.6.3",
|
|
90
|
-
"use-intl": "^3.17.
|
|
90
|
+
"use-intl": "^3.17.3"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -104,11 +104,11 @@
|
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"path": "dist/production/navigation.react-client.js",
|
|
107
|
-
"limit": "3.
|
|
107
|
+
"limit": "3.55 KB"
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"path": "dist/production/navigation.react-server.js",
|
|
111
|
-
"limit": "18.
|
|
111
|
+
"limit": "18.355 KB"
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"path": "dist/production/server.react-client.js",
|
|
@@ -120,12 +120,12 @@
|
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
122
|
"path": "dist/production/middleware.js",
|
|
123
|
-
"limit": "6.
|
|
123
|
+
"limit": "6.525 KB"
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
"path": "dist/production/routing.js",
|
|
127
127
|
"limit": "0 KB"
|
|
128
128
|
}
|
|
129
129
|
],
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "ed4681fa70b8f67a97e1364deaabf58df302d80c"
|
|
131
131
|
}
|