next-intl 3.7.0 → 3.9.0
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 +1 -1
- package/dist/development/middleware/resolveLocale.js +4 -3
- package/dist/development/middleware/utils.js +11 -7
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/middleware/utils.js +1 -1
- package/dist/types/src/middleware/utils.d.ts +3 -2
- package/package.json +7 -7
|
@@ -73,7 +73,7 @@ function createMiddleware(config) {
|
|
|
73
73
|
return server.NextResponse.redirect(urlObj.toString());
|
|
74
74
|
}
|
|
75
75
|
const normalizedPathname = utils.getNormalizedPathname(request.nextUrl.pathname, configWithDefaults.locales);
|
|
76
|
-
const pathLocale = utils.
|
|
76
|
+
const pathLocale = utils.getPathnameLocale(request.nextUrl.pathname, configWithDefaults.locales);
|
|
77
77
|
const hasLocalePrefix = pathLocale != null;
|
|
78
78
|
let response;
|
|
79
79
|
let internalTemplateName;
|
|
@@ -46,9 +46,10 @@ function resolveLocaleFromPrefix(_ref, requestHeaders, requestCookies, pathname)
|
|
|
46
46
|
|
|
47
47
|
// Prio 1: Use route prefix
|
|
48
48
|
if (pathname) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const pathLocaleCandidate = utils.getFirstPathnameSegment(pathname);
|
|
50
|
+
const matchedLocale = utils.findCaseInsensitiveLocale(pathLocaleCandidate, locales);
|
|
51
|
+
if (matchedLocale) {
|
|
52
|
+
locale = matchedLocale;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var utils = require('../shared/utils.js');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function getFirstPathnameSegment(pathname) {
|
|
8
8
|
return pathname.split('/')[1];
|
|
9
9
|
}
|
|
10
10
|
function getInternalTemplate(pathnames, pathname) {
|
|
@@ -44,16 +44,19 @@ function getNormalizedPathname(pathname, locales) {
|
|
|
44
44
|
if (!pathname.endsWith('/')) {
|
|
45
45
|
pathname += '/';
|
|
46
46
|
}
|
|
47
|
-
const match = pathname.match("^/(".concat(locales.join('|'), ")/(.*)"));
|
|
47
|
+
const match = pathname.match(new RegExp("^/(".concat(locales.join('|'), ")/(.*)"), 'i'));
|
|
48
48
|
let result = match ? '/' + match[2] : pathname;
|
|
49
49
|
if (result !== '/') {
|
|
50
50
|
result = normalizeTrailingSlash(result);
|
|
51
51
|
}
|
|
52
52
|
return result;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
function findCaseInsensitiveLocale(candidate, locales) {
|
|
55
|
+
return locales.find(locale => locale.toLowerCase() === candidate.toLowerCase());
|
|
56
|
+
}
|
|
57
|
+
function getPathnameLocale(pathname, locales) {
|
|
58
|
+
const pathLocaleCandidate = getFirstPathnameSegment(pathname);
|
|
59
|
+
const pathLocale = findCaseInsensitiveLocale(pathLocaleCandidate, locales) ? pathLocaleCandidate : undefined;
|
|
57
60
|
return pathLocale;
|
|
58
61
|
}
|
|
59
62
|
function getRouteParams(template, pathname) {
|
|
@@ -135,14 +138,15 @@ function normalizeTrailingSlash(pathname) {
|
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
exports.applyBasePath = applyBasePath;
|
|
141
|
+
exports.findCaseInsensitiveLocale = findCaseInsensitiveLocale;
|
|
138
142
|
exports.formatPathname = formatPathname;
|
|
139
143
|
exports.formatTemplatePathname = formatTemplatePathname;
|
|
140
144
|
exports.getBestMatchingDomain = getBestMatchingDomain;
|
|
145
|
+
exports.getFirstPathnameSegment = getFirstPathnameSegment;
|
|
141
146
|
exports.getHost = getHost;
|
|
142
147
|
exports.getInternalTemplate = getInternalTemplate;
|
|
143
|
-
exports.getKnownLocaleFromPathname = getKnownLocaleFromPathname;
|
|
144
|
-
exports.getLocaleFromPathname = getLocaleFromPathname;
|
|
145
148
|
exports.getNormalizedPathname = getNormalizedPathname;
|
|
146
149
|
exports.getPathWithSearch = getPathWithSearch;
|
|
150
|
+
exports.getPathnameLocale = getPathnameLocale;
|
|
147
151
|
exports.getRouteParams = getRouteParams;
|
|
148
152
|
exports.isLocaleSupportedOnDomain = isLocaleSupportedOnDomain;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{COOKIE_LOCALE_NAME as t,COOKIE_SAME_SITE as a,COOKIE_MAX_AGE as n,HEADER_LOCALE_NAME as l}from"../shared/constants.js";import{matchesPathname as o}from"../shared/utils.js";import r from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import{isLocaleSupportedOnDomain as i,getNormalizedPathname as c,
|
|
1
|
+
import{NextResponse as e}from"next/server";import{COOKIE_LOCALE_NAME as t,COOKIE_SAME_SITE as a,COOKIE_MAX_AGE as n,HEADER_LOCALE_NAME as l}from"../shared/constants.js";import{matchesPathname as o}from"../shared/utils.js";import r from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import{isLocaleSupportedOnDomain as i,getNormalizedPathname as c,getPathnameLocale as d,getInternalTemplate as f,formatTemplatePathname as u,getPathWithSearch as m,getBestMatchingDomain as h,applyBasePath as p}from"./utils.js";function v(v){const x=function(e){var t,a,n;return{...e,alternateLinks:null===(t=e.alternateLinks)||void 0===t||t,localePrefix:null!==(a=e.localePrefix)&&void 0!==a?a:"always",localeDetection:null===(n=e.localeDetection)||void 0===n||n}}(v);return function(v){var P,U;const{domain:L,locale:g}=s(x,v.headers,v.cookies,v.nextUrl.pathname),k=x.localeDetection&&(null===(P=v.cookies.get(t))||void 0===P?void 0:P.value)!==g,w=L?L.defaultLocale===g:g===x.defaultLocale,b=(null===(U=x.domains)||void 0===U?void 0:U.filter((e=>i(g,e))))||[],j=null!=x.domains&&!L;function y(t){const a=new URL(t,v.url);return v.nextUrl.basePath&&(a.pathname=p(a.pathname,v.nextUrl.basePath)),e.rewrite(a,function(){const e=new Headers(v.headers);return e.set(l,g),{request:{headers:e}}}())}function D(t,a){const n=new URL(t,v.url);if(b.length>0&&!a){const e=h(L,g,b);e&&(a=e.domain,e.defaultLocale===g&&"as-needed"===x.localePrefix&&n.pathname.startsWith("/".concat(g))&&(n.pathname=c(n.pathname,x.locales)))}var l;a&&(n.protocol=null!==(l=v.headers.get("x-forwarded-proto"))&&void 0!==l?l:v.nextUrl.protocol,n.port="",n.host=a);return v.nextUrl.basePath&&(n.pathname=p(n.pathname,v.nextUrl.basePath)),e.redirect(n.toString())}const q=c(v.nextUrl.pathname,x.locales),A=d(v.nextUrl.pathname,x.locales),H=null!=A;let R,S,z=v.nextUrl.pathname;if(x.pathnames){let e;if([e=g,S]=f(x.pathnames,q),S){const t=x.pathnames[S],a="string"==typeof t?t:t[g];if(o(a,q))z=u(q,a,S,A);else{const n=x.defaultLocale===g||(null==L?void 0:L.defaultLocale)===g;R=D(m(u(q,"string"==typeof t?t:t[e],a,A||!n?g:void 0),v.nextUrl.search))}}}if(!R)if("/"===z){const e=m("/".concat(g),v.nextUrl.search);R="never"===x.localePrefix||w&&"as-needed"===x.localePrefix?y(e):D(e)}else{const e=m(z,v.nextUrl.search);if(H){const t=m(q,v.nextUrl.search);if("never"===x.localePrefix)R=D(t);else if(A===g)if(w&&"as-needed"===x.localePrefix)R=D(t);else if(x.domains){const a=h(L,A,b);R=(null==L?void 0:L.domain)===(null==a?void 0:a.domain)||j?y(e):D(t,null==a?void 0:a.domain)}else R=y(e);else R=D("/".concat(g).concat(t))}else R="never"===x.localePrefix||w&&("as-needed"===x.localePrefix||x.domains)?y("/".concat(g).concat(e)):D("/".concat(g).concat(e))}var V;(k&&R.cookies.set(t,g,{path:v.nextUrl.basePath||void 0,sameSite:a,maxAge:n}),"never"!==x.localePrefix&&x.alternateLinks&&x.locales.length>1)&&R.headers.set("Link",r({config:x,localizedPathnames:null!=S?null===(V=x.pathnames)||void 0===V?void 0:V[S]:void 0,request:v,resolvedLocale:g}));return R}}export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as t}from"@formatjs/intl-localematcher";import o from"negotiator";import{COOKIE_LOCALE_NAME as e}from"../shared/constants.js";import{
|
|
1
|
+
import{match as t}from"@formatjs/intl-localematcher";import o from"negotiator";import{COOKIE_LOCALE_NAME as e}from"../shared/constants.js";import{getFirstPathnameSegment as n,findCaseInsensitiveLocale as a,isLocaleSupportedOnDomain as l,getHost as c}from"./utils.js";function r(l,c,r,i){let s,{defaultLocale:u,localeDetection:f,locales:d}=l;if(i){const t=n(i),o=a(t,d);o&&(s=o)}if(!s&&f&&r&&r.has(e)){var m;const t=null===(m=r.get(e))||void 0===m?void 0:m.value;t&&d.includes(t)&&(s=t)}return!s&&f&&c&&(s=function(e,n,a){let l;const c=new o({headers:{"accept-language":e.get("accept-language")||void 0}}).languages();try{l=t(c,n,a)}catch(t){}return l}(c,d,u)),s||(s=u),s}function i(t,o,e,n){const{domains:a}=t,i=r(t,o,e,n);if(a){const t=function(t,o){var e;let n=c(t);if(n=null===(e=n)||void 0===e?void 0:e.replace(/:\d+$/,""),n&&o)return o.find((t=>t.domain===n))}(o,a),e=n&&n.startsWith("/".concat(i));if(t)return{locale:l(i,t)||e?i:t.defaultLocale,domain:t}}return{locale:i}}function s(t,o,e,n){return t.domains?i(t,o,e,n):{locale:r(t,o,e,n)}}export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchesPathname as n,templateToRegex as t}from"../shared/utils.js";function e(n){return n.split("/")[1]}function o(t,e){for(const[o,r]of Object.entries(t))if("string"==typeof r){if(n(r,e))return[void 0,o]}else for(const[t,
|
|
1
|
+
import{matchesPathname as n,templateToRegex as t}from"../shared/utils.js";function e(n){return n.split("/")[1]}function o(t,e){for(const[o,r]of Object.entries(t))if("string"==typeof r){if(n(r,e))return[void 0,o]}else for(const[t,c]of Object.entries(r))if(n(c,e))return[t,o];return[void 0,void 0]}function r(n,t,e,o){const r=u(t,n);let c="";return o&&(c="/".concat(o)),c+=f(e,r),c=p(c),c}function c(n,t){n.endsWith("/")||(n+="/");const e=n.match(new RegExp("^/(".concat(t.join("|"),")/(.*)"),"i"));let o=e?"/"+e[2]:n;return"/"!==o&&(o=p(o)),o}function l(n,t){return t.find((t=>t.toLowerCase()===n.toLowerCase()))}function i(n,t){const o=e(n);return l(o,t)?o:void 0}function u(n,e){const o=t(n).exec(e);if(!o)return;const r={};for(let t=1;t<o.length;t++){var c;const e=null===(c=n.match(/\[([^\]]+)\]/g))||void 0===c?void 0:c[t-1].replace(/[[\]]/g,"");e&&(r[e]=o[t])}return r}function f(n,t){if(!t)return n;let e=n=n.replaceAll("[[","[").replaceAll("]]","]");return Object.entries(t).forEach((n=>{let[t,o]=n;e=e.replace("[".concat(t,"]"),o)})),e}function s(n,t){let e=n;return t&&(e+=t),e}function a(n){var t,e;return null!==(t=null!==(e=n.get("x-forwarded-host"))&&void 0!==e?e:n.get("host"))&&void 0!==t?t:void 0}function d(n,t){return t.defaultLocale===n||!t.locales||t.locales.includes(n)}function v(n,t,e){let o;return n&&d(t,n)&&(o=n),o||(o=e.find((n=>n.defaultLocale===t))),o||(o=e.find((n=>null!=n.locales&&n.locales.includes(t)))),o||null!=(null==n?void 0:n.locales)||(o=n),o||(o=e.find((n=>!n.locales))),o}function h(n,t){return p(t+n)}function p(n){return n.endsWith("/")&&(n=n.slice(0,-1)),n}export{h as applyBasePath,l as findCaseInsensitiveLocale,f as formatPathname,r as formatTemplatePathname,v as getBestMatchingDomain,e as getFirstPathnameSegment,a as getHost,o as getInternalTemplate,c as getNormalizedPathname,s as getPathWithSearch,i as getPathnameLocale,u as getRouteParams,d as isLocaleSupportedOnDomain};
|
|
@@ -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"),n=require("./getAlternateLinksHeaderValue.js"),l=require("./resolveLocale.js"),o=require("./utils.js");exports.default=function(r){const s=function(e){var a,t,n;return{...e,alternateLinks:null===(a=e.alternateLinks)||void 0===a||a,localePrefix:null!==(t=e.localePrefix)&&void 0!==t?t:"always",localeDetection:null===(n=e.localeDetection)||void 0===n||n}}(r);return function(r){var i,c;const{domain:d,locale:h}=l.default(s,r.headers,r.cookies,r.nextUrl.pathname),u=s.localeDetection&&(null===(i=r.cookies.get(a.COOKIE_LOCALE_NAME))||void 0===i?void 0:i.value)!==h,m=d?d.defaultLocale===h:h===s.defaultLocale,f=(null===(c=s.domains)||void 0===c?void 0:c.filter((e=>o.isLocaleSupportedOnDomain(h,e))))||[],p=null!=s.domains&&!d;function v(t){const n=new URL(t,r.url);return r.nextUrl.basePath&&(n.pathname=o.applyBasePath(n.pathname,r.nextUrl.basePath)),e.NextResponse.rewrite(n,function(){const e=new Headers(r.headers);return e.set(a.HEADER_LOCALE_NAME,h),{request:{headers:e}}}())}function x(a,t){const n=new URL(a,r.url);if(f.length>0&&!t){const e=o.getBestMatchingDomain(d,h,f);e&&(t=e.domain,e.defaultLocale===h&&"as-needed"===s.localePrefix&&n.pathname.startsWith("/".concat(h))&&(n.pathname=o.getNormalizedPathname(n.pathname,s.locales)))}var l;t&&(n.protocol=null!==(l=r.headers.get("x-forwarded-proto"))&&void 0!==l?l:r.nextUrl.protocol,n.port="",n.host=t);return r.nextUrl.basePath&&(n.pathname=o.applyBasePath(n.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(n.toString())}const P=o.getNormalizedPathname(r.nextUrl.pathname,s.locales),g=o.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),n=require("./getAlternateLinksHeaderValue.js"),l=require("./resolveLocale.js"),o=require("./utils.js");exports.default=function(r){const s=function(e){var a,t,n;return{...e,alternateLinks:null===(a=e.alternateLinks)||void 0===a||a,localePrefix:null!==(t=e.localePrefix)&&void 0!==t?t:"always",localeDetection:null===(n=e.localeDetection)||void 0===n||n}}(r);return function(r){var i,c;const{domain:d,locale:h}=l.default(s,r.headers,r.cookies,r.nextUrl.pathname),u=s.localeDetection&&(null===(i=r.cookies.get(a.COOKIE_LOCALE_NAME))||void 0===i?void 0:i.value)!==h,m=d?d.defaultLocale===h:h===s.defaultLocale,f=(null===(c=s.domains)||void 0===c?void 0:c.filter((e=>o.isLocaleSupportedOnDomain(h,e))))||[],p=null!=s.domains&&!d;function v(t){const n=new URL(t,r.url);return r.nextUrl.basePath&&(n.pathname=o.applyBasePath(n.pathname,r.nextUrl.basePath)),e.NextResponse.rewrite(n,function(){const e=new Headers(r.headers);return e.set(a.HEADER_LOCALE_NAME,h),{request:{headers:e}}}())}function x(a,t){const n=new URL(a,r.url);if(f.length>0&&!t){const e=o.getBestMatchingDomain(d,h,f);e&&(t=e.domain,e.defaultLocale===h&&"as-needed"===s.localePrefix&&n.pathname.startsWith("/".concat(h))&&(n.pathname=o.getNormalizedPathname(n.pathname,s.locales)))}var l;t&&(n.protocol=null!==(l=r.headers.get("x-forwarded-proto"))&&void 0!==l?l:r.nextUrl.protocol,n.port="",n.host=t);return r.nextUrl.basePath&&(n.pathname=o.applyBasePath(n.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(n.toString())}const P=o.getNormalizedPathname(r.nextUrl.pathname,s.locales),g=o.getPathnameLocale(r.nextUrl.pathname,s.locales),L=null!=g;let U,E,O=r.nextUrl.pathname;if(s.pathnames){let e;if([e=h,E]=o.getInternalTemplate(s.pathnames,P),E){const a=s.pathnames[E],n="string"==typeof a?a:a[h];if(t.matchesPathname(n,P))O=o.formatTemplatePathname(P,n,E,g);else{const t=s.defaultLocale===h||(null==d?void 0:d.defaultLocale)===h;U=x(o.getPathWithSearch(o.formatTemplatePathname(P,"string"==typeof a?a:a[e],n,g||!t?h:void 0),r.nextUrl.search))}}}if(!U)if("/"===O){const e=o.getPathWithSearch("/".concat(h),r.nextUrl.search);U="never"===s.localePrefix||m&&"as-needed"===s.localePrefix?v(e):x(e)}else{const e=o.getPathWithSearch(O,r.nextUrl.search);if(L){const a=o.getPathWithSearch(P,r.nextUrl.search);if("never"===s.localePrefix)U=x(a);else if(g===h)if(m&&"as-needed"===s.localePrefix)U=x(a);else if(s.domains){const t=o.getBestMatchingDomain(d,g,f);U=(null==d?void 0:d.domain)===(null==t?void 0:t.domain)||p?v(e):x(a,null==t?void 0:t.domain)}else U=v(e);else U=x("/".concat(h).concat(a))}else U="never"===s.localePrefix||m&&("as-needed"===s.localePrefix||s.domains)?v("/".concat(h).concat(e)):x("/".concat(h).concat(e))}var A;(u&&U.cookies.set(a.COOKIE_LOCALE_NAME,h,{path:r.nextUrl.basePath||void 0,sameSite:a.COOKIE_SAME_SITE,maxAge:a.COOKIE_MAX_AGE}),"never"!==s.localePrefix&&s.alternateLinks&&s.locales.length>1)&&U.headers.set("Link",n.default({config:s,localizedPathnames:null!=E?null===(A=s.pathnames)||void 0===A?void 0:A[E]:void 0,request:r,resolvedLocale:h}));return U}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),n=require("../shared/constants.js"),a=require("./utils.js");function o(e){return e&&e.__esModule?e:{default:e}}var r=o(t);function i(t,o,i,l){let c,{defaultLocale:u,localeDetection:s,locales:d}=t;if(l){const e=a.getFirstPathnameSegment(l),t=a.findCaseInsensitiveLocale(e,d);t&&(c=t)}if(!c&&s&&i&&i.has(n.COOKIE_LOCALE_NAME)){var f;const e=null===(f=i.get(n.COOKIE_LOCALE_NAME))||void 0===f?void 0:f.value;e&&d.includes(e)&&(c=e)}return!c&&s&&o&&(c=function(t,n,a){let o;const i=new r.default({headers:{"accept-language":t.get("accept-language")||void 0}}).languages();try{o=e.match(i,n,a)}catch(e){}return o}(o,d,u)),c||(c=u),c}function l(e,t,n,o){const{domains:r}=e,l=i(e,t,n,o);if(r){const e=function(e,t){var n;let o=a.getHost(e);if(o=null===(n=o)||void 0===n?void 0:n.replace(/:\d+$/,""),o&&t)return t.find((e=>e.domain===o))}(t,r),n=o&&o.startsWith("/".concat(l));if(e)return{locale:a.isLocaleSupportedOnDomain(l,e)||n?l:e.defaultLocale,domain:e}}return{locale:l}}exports.default=function(e,t,n,a){return e.domains?l(e,t,n,a):{locale:i(e,t,n,a)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.split("/")[1]}function n(t,n){const o=e.templateToRegex(t).exec(n);if(!o)return;const r={};for(let e=1;e<o.length;e++){var a;const n=null===(a=t.match(/\[([^\]]+)\]/g))||void 0===a?void 0:a[e-1].replace(/[[\]]/g,"");n&&(r[n]=o[e])}return r}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.split("/")[1]}function n(e,t){return t.find((t=>t.toLowerCase()===e.toLowerCase()))}function o(t,n){const o=e.templateToRegex(t).exec(n);if(!o)return;const r={};for(let e=1;e<o.length;e++){var a;const n=null===(a=t.match(/\[([^\]]+)\]/g))||void 0===a?void 0:a[e-1].replace(/[[\]]/g,"");n&&(r[n]=o[e])}return r}function r(e,t){if(!t)return e;let n=e=e.replaceAll("[[","[").replaceAll("]]","]");return Object.entries(t).forEach((e=>{let[t,o]=e;n=n.replace("[".concat(t,"]"),o)})),n}function a(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function l(e){return e.endsWith("/")&&(e=e.slice(0,-1)),e}exports.applyBasePath=function(e,t){return l(t+e)},exports.findCaseInsensitiveLocale=n,exports.formatPathname=r,exports.formatTemplatePathname=function(e,t,n,a){const s=o(t,e);let c="";return a&&(c="/".concat(a)),c+=r(n,s),c=l(c),c},exports.getBestMatchingDomain=function(e,t,n){let o;return e&&a(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},exports.getFirstPathnameSegment=t,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){for(const[o,r]of Object.entries(t))if("string"==typeof r){const t=r;if(e.matchesPathname(t,n))return[void 0,o]}else for(const[t,a]of Object.entries(r))if(e.matchesPathname(a,n))return[t,o];return[void 0,void 0]},exports.getNormalizedPathname=function(e,t){e.endsWith("/")||(e+="/");const n=e.match(new RegExp("^/(".concat(t.join("|"),")/(.*)"),"i"));let o=n?"/"+n[2]:e;return"/"!==o&&(o=l(o)),o},exports.getPathWithSearch=function(e,t){let n=e;return t&&(n+=t),n},exports.getPathnameLocale=function(e,o){const r=t(e);return n(r,o)?r:void 0},exports.getRouteParams=o,exports.isLocaleSupportedOnDomain=a;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AllLocales } from '../shared/types';
|
|
2
2
|
import { DomainConfig, MiddlewareConfigWithDefaults } from './NextIntlMiddlewareConfig';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getFirstPathnameSegment(pathname: string): string;
|
|
4
4
|
export declare function getInternalTemplate<Locales extends AllLocales, Pathnames extends NonNullable<MiddlewareConfigWithDefaults<Locales>['pathnames']>>(pathnames: Pathnames, pathname: string): [Locales[number] | undefined, keyof Pathnames | undefined];
|
|
5
5
|
export declare function formatTemplatePathname(sourcePathname: string, sourceTemplate: string, targetTemplate: string, localePrefix?: string): string;
|
|
6
6
|
/**
|
|
7
7
|
* Removes potential locales from the pathname.
|
|
8
8
|
*/
|
|
9
9
|
export declare function getNormalizedPathname<Locales extends AllLocales>(pathname: string, locales: Locales): string;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function findCaseInsensitiveLocale<Locales extends AllLocales>(candidate: string, locales: Locales): string | undefined;
|
|
11
|
+
export declare function getPathnameLocale<Locales extends AllLocales>(pathname: string, locales: Locales): Locales[number] | undefined;
|
|
11
12
|
export declare function getRouteParams(template: string, pathname: string): Record<string, string> | undefined;
|
|
12
13
|
export declare function formatPathname(template: string, params?: object): string;
|
|
13
14
|
export declare function getPathWithSearch(pathname: string, search: string | undefined): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
84
84
|
"negotiator": "^0.6.3",
|
|
85
|
-
"use-intl": "^3.
|
|
85
|
+
"use-intl": "^3.9.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -114,11 +114,11 @@
|
|
|
114
114
|
"size-limit": [
|
|
115
115
|
{
|
|
116
116
|
"path": "dist/production/index.react-client.js",
|
|
117
|
-
"limit": "
|
|
117
|
+
"limit": "13.055 KB"
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
120
|
"path": "dist/production/index.react-server.js",
|
|
121
|
-
"limit": "13.
|
|
121
|
+
"limit": "13.765 KB"
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
"path": "dist/production/navigation.react-client.js",
|
|
@@ -134,12 +134,12 @@
|
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
136
|
"path": "dist/production/server.react-server.js",
|
|
137
|
-
"limit": "
|
|
137
|
+
"limit": "13.05 KB"
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
"path": "dist/production/middleware.js",
|
|
141
|
-
"limit": "5.
|
|
141
|
+
"limit": "5.855 KB"
|
|
142
142
|
}
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "5282232e2c51582136c08f8af8b4412442615688"
|
|
145
145
|
}
|