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.replace(/\[([^\]]+)\]/g, match => {
70
- if (match.startsWith('[...')) return '(.*)';
71
- if (match.startsWith('[[...')) return '(.*)';
72
- return '([^/]+)';
73
- })
74
- // Clean up regex match remainders from optional catchall ('[[...slug]]')
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
 
@@ -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,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,(t=>t.startsWith("[...")||t.startsWith("[[...")?"(.*)":"([^/]+)")).replaceAll("(.*)]","(.*)");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
+ 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 t(t){const e="object"==typeof t?t.pathname:t;return null!=e&&!e.startsWith("/")}function e(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function n(t,e){let n;return"string"==typeof t?n=r(e,t):(n={...t},t.pathname&&(n.pathname=r(e,t.pathname))),n}function r(t,e){let n="/"+t;return/^\/(\?.*)?$/.test(e)&&(e=e.slice(1)),n+=e,n}function o(t,e){const n="/".concat(t);return e===n||e.startsWith("".concat(n,"/"))}function a(t){const e=t.replace(/\[([^\]]+)\]/g,(t=>t.startsWith("[...")||t.startsWith("[[...")?"(.*)":"([^/]+)")).replaceAll("(.*)]","(.*)");return new RegExp("^".concat(e,"$"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.hasPathnamePrefixed=o,exports.isLocalHref=e,exports.isRelativeHref=t,exports.localizeHref=function(r,a){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,c=arguments.length>3?arguments[3]:void 0;if(!e(r)||t(r))return r;const i=a!==s,l=null==a||o(a,c);return(i||l)&&null!=a?n(r,a):r},exports.matchesPathname=function(t,e){return a(t).test(e)},exports.prefixHref=n,exports.prefixPathname=r,exports.templateToRegex=a,exports.unlocalizePathname=function(t,e){return t.replace(new RegExp("^/".concat(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.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.2",
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.2"
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": "2a6199609c0a77f897d994c8d52796f5615bcfff"
144
+ "gitHead": "0df6e429ad3dca9e3ac9101cad6ac9ee034e24f5"
145
145
  }