next-intl 3.9.2 → 3.9.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.
|
@@ -66,13 +66,13 @@ pathname) {
|
|
|
66
66
|
return regex.test(pathname);
|
|
67
67
|
}
|
|
68
68
|
function templateToRegex(template) {
|
|
69
|
-
const regexPattern = template
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
.replaceAll(
|
|
69
|
+
const regexPattern = template
|
|
70
|
+
// Replace optional catchall ('[[...slug]]')
|
|
71
|
+
.replaceAll(/\[\[(\.\.\.[^\]]+)\]\]/g, '?(.*)')
|
|
72
|
+
// Replace catchall ('[...slug]')
|
|
73
|
+
.replaceAll(/\[(\.\.\.[^\]]+)\]/g, '(.+)')
|
|
74
|
+
// Replace regular parameter ('[slug]')
|
|
75
|
+
.replaceAll(/\[([^\]]+)\]/g, '([^/]+)');
|
|
76
76
|
return new RegExp("^".concat(regexPattern, "$"));
|
|
77
77
|
}
|
|
78
78
|
|
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,u=arguments.length>3?arguments[3]:void 0;if(!n(e)||t(e))return e;const a=c!==o,i=null==c||l(c,u);return(a||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 l(t,n){const e="/".concat(t);return n===e||n.startsWith("".concat(e,"/"))}function u(t,n){return a(t).test(n)}function a(t){const n=t.replaceAll(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replaceAll(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replaceAll(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(n,"$"))}export{l as hasPathnamePrefixed,n as isLocalHref,t as isRelativeHref,e as localizeHref,u as matchesPathname,r as prefixHref,o as prefixPathname,a as templateToRegex,c as unlocalizePathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function
|
|
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.replaceAll(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replaceAll(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replaceAll(/\[([^\]]+)\]/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 l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,c=arguments.length>3?arguments[3]:void 0;if(!t(r)||e(r))return r;const s=a!==l,u=null==a||o(a,c);return(s||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.3",
|
|
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.3"
|
|
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": "0df6e429ad3dca9e3ac9101cad6ac9ee034e24f5"
|
|
145
145
|
}
|