next-intl 3.9.4 → 3.9.5
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/utils.js +1 -1
- package/dist/development/shared/utils.js +3 -3
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/production/middleware/utils.js +1 -1
- package/dist/production/shared/utils.js +1 -1
- package/package.json +3 -3
|
@@ -76,7 +76,7 @@ function formatPathname(template, params) {
|
|
|
76
76
|
|
|
77
77
|
// Simplify syntax for optional catchall ('[[...slug]]') so
|
|
78
78
|
// we can replace the value with simple interpolation
|
|
79
|
-
template = template.
|
|
79
|
+
template = template.replace(/\[\[/g, '[').replace(/\]\]/g, ']');
|
|
80
80
|
let result = template;
|
|
81
81
|
Object.entries(params).forEach(_ref => {
|
|
82
82
|
let [key, value] = _ref;
|
|
@@ -68,11 +68,11 @@ pathname) {
|
|
|
68
68
|
function templateToRegex(template) {
|
|
69
69
|
const regexPattern = template
|
|
70
70
|
// Replace optional catchall ('[[...slug]]')
|
|
71
|
-
.
|
|
71
|
+
.replace(/\[\[(\.\.\.[^\]]+)\]\]/g, '?(.*)')
|
|
72
72
|
// Replace catchall ('[...slug]')
|
|
73
|
-
.
|
|
73
|
+
.replace(/\[(\.\.\.[^\]]+)\]/g, '(.+)')
|
|
74
74
|
// Replace regular parameter ('[slug]')
|
|
75
|
-
.
|
|
75
|
+
.replace(/\[([^\]]+)\]/g, '([^/]+)');
|
|
76
76
|
return new RegExp("^".concat(regexPattern, "$"));
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -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,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=
|
|
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=h(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=h(o)),o}function i(n,t){return t.find((t=>t.toLowerCase()===n.toLowerCase()))}function l(n,t){const o=e(n);return i(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.replace(/\[\[/g,"[").replace(/\]\]/g,"]");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 g(n,t){return h(t+n)}function h(n){return n.endsWith("/")&&(n=n.slice(0,-1)),n}export{g as applyBasePath,i 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,l as getPathnameLocale,u as getRouteParams,d as isLocaleSupportedOnDomain};
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){const n="object"==typeof t?t.pathname:t;return null!=n&&!n.startsWith("/")}function n(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function e(e,c){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:c,
|
|
1
|
+
function t(t){const n="object"==typeof t?t.pathname:t;return null!=n&&!n.startsWith("/")}function n(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function e(e,c){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:c,a=arguments.length>3?arguments[3]:void 0;if(!n(e)||t(e))return e;const l=c!==o,i=null==c||u(c,a);return(l||i)&&null!=c?r(e,c):e}function r(t,n){let e;return"string"==typeof t?e=o(n,t):(e={...t},t.pathname&&(e.pathname=o(n,t.pathname))),e}function c(t,n){return t.replace(new RegExp("^/".concat(n)),"")||"/"}function o(t,n){let e="/"+t;return/^\/(\?.*)?$/.test(n)&&(n=n.slice(1)),e+=n,e}function u(t,n){const e="/".concat(t);return n===e||n.startsWith("".concat(e,"/"))}function a(t,n){return l(t).test(n)}function l(t){const n=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(n,"$"))}export{u as hasPathnamePrefixed,n as isLocalHref,t as isRelativeHref,e as localizeHref,a as matchesPathname,r as prefixHref,o as prefixPathname,l as templateToRegex,c as unlocalizePathname};
|
|
@@ -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(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.
|
|
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.replace(/\[\[/g,"[").replace(/\]\]/g,"]");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 s(e){return e.endsWith("/")&&(e=e.slice(0,-1)),e}exports.applyBasePath=function(e,t){return s(t+e)},exports.findCaseInsensitiveLocale=n,exports.formatPathname=r,exports.formatTemplatePathname=function(e,t,n,a){const c=o(t,e);let i="";return a&&(i="/".concat(a)),i+=r(n,c),i=s(i),i},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=s(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 +1 @@
|
|
|
1
|
-
"use strict";function e(e){const t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}function t(e){if("object"==typeof e)return null==e.host&&null==e.hostname;return!/^[a-z]+:/i.test(e)}function n(e,t){let n;return"string"==typeof e?n=r(t,e):(n={...e},e.pathname&&(n.pathname=r(t,e.pathname))),n}function r(e,t){let n="/"+e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function o(e,t){const n="/".concat(e);return t===n||t.startsWith("".concat(n,"/"))}function a(e){const t=e.
|
|
1
|
+
"use strict";function e(e){const t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}function t(e){if("object"==typeof e)return null==e.host&&null==e.hostname;return!/^[a-z]+:/i.test(e)}function n(e,t){let n;return"string"==typeof e?n=r(t,e):(n={...e},e.pathname&&(n.pathname=r(t,e.pathname))),n}function r(e,t){let n="/"+e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function o(e,t){const n="/".concat(e);return t===n||t.startsWith("".concat(n,"/"))}function a(e){const t=e.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.hasPathnamePrefixed=o,exports.isLocalHref=t,exports.isRelativeHref=e,exports.localizeHref=function(r,a){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,s=arguments.length>3?arguments[3]:void 0;if(!t(r)||e(r))return r;const l=a!==c,u=null==a||o(a,s);return(l||u)&&null!=a?n(r,a):r},exports.matchesPathname=function(e,t){return a(e).test(t)},exports.prefixHref=n,exports.prefixPathname=r,exports.templateToRegex=a,exports.unlocalizePathname=function(e,t){return e.replace(new RegExp("^/".concat(t)),"")||"/"};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.5",
|
|
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.9.
|
|
85
|
+
"use-intl": "^3.9.5"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"limit": "5.855 KB"
|
|
142
142
|
}
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "35069bac25c03cd6fd10c802fcd8627e3eac75dd"
|
|
145
145
|
}
|