next-intl 3.17.2 → 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.
|
@@ -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{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("../../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;
|
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",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"limit": "0 KB"
|
|
128
128
|
}
|
|
129
129
|
],
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "ed4681fa70b8f67a97e1364deaabf58df302d80c"
|
|
131
131
|
}
|