next-intl 3.19.1 → 3.19.2
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.
|
@@ -83,6 +83,9 @@ function getLocalePrefixes(locales, localePrefix) {
|
|
|
83
83
|
}
|
|
84
84
|
function getPathnameMatch(pathname, locales, localePrefix) {
|
|
85
85
|
const localePrefixes = getLocalePrefixes(locales, localePrefix);
|
|
86
|
+
|
|
87
|
+
// More specific ones first
|
|
88
|
+
localePrefixes.sort((a, b) => b[1].length - a[1].length);
|
|
86
89
|
for (const [locale, prefix] of localePrefixes) {
|
|
87
90
|
let exact, matches;
|
|
88
91
|
if (pathname === prefix || pathname.startsWith(prefix + '/')) {
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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);r.sort(((e,t)=>t[1].length-e[1].length));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 h(e,t,n){let r=e;return t&&(r=c(t,r)),n&&(r+=n),r}function p(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,h as formatPathname,d as formatPathnameTemplate,i as formatTemplatePathname,v as getBestMatchingDomain,p 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
|
-
"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
|
+
"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);o.sort(((e,t)=>t[1].length-e[1].length));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,"/")};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.2",
|
|
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.2"
|
|
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": "ea69a82810f497ae2e733efd52eb3744238ff930"
|
|
97
97
|
}
|