next-intl 3.15.2 → 3.15.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.
@@ -4,54 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var utils = require('../shared/utils.js');
6
6
 
7
- function isOptionalCatchAllSegment(pathname) {
8
- return pathname.includes('[[...');
9
- }
10
- function isCatchAllSegment(pathname) {
11
- return pathname.includes('[...');
12
- }
13
- function isDynamicSegment(pathname) {
14
- return pathname.includes('[');
15
- }
16
- function comparePathnamePairs(a, b) {
17
- const pathA = a.split('/');
18
- const pathB = b.split('/');
19
- const maxLength = Math.max(pathA.length, pathB.length);
20
- for (let i = 0; i < maxLength; i++) {
21
- const segmentA = pathA[i];
22
- const segmentB = pathB[i];
23
-
24
- // If one of the paths ends, prioritize the shorter path
25
- if (!segmentA && segmentB) return -1;
26
- if (segmentA && !segmentB) return 1;
27
-
28
- // Prioritize static segments over dynamic segments
29
- if (!isDynamicSegment(segmentA) && isDynamicSegment(segmentB)) return -1;
30
- if (isDynamicSegment(segmentA) && !isDynamicSegment(segmentB)) return 1;
31
-
32
- // Prioritize non-catch-all segments over catch-all segments
33
- if (!isCatchAllSegment(segmentA) && isCatchAllSegment(segmentB)) return -1;
34
- if (isCatchAllSegment(segmentA) && !isCatchAllSegment(segmentB)) return 1;
35
-
36
- // Prioritize non-optional catch-all segments over optional catch-all segments
37
- if (!isOptionalCatchAllSegment(segmentA) && isOptionalCatchAllSegment(segmentB)) {
38
- return -1;
39
- }
40
- if (isOptionalCatchAllSegment(segmentA) && !isOptionalCatchAllSegment(segmentB)) {
41
- return 1;
42
- }
43
- if (segmentA === segmentB) continue;
44
- }
45
-
46
- // Both pathnames are completely static
47
- return 0;
48
- }
49
- function getSortedPathnames(pathnames) {
50
- const sortedPathnames = pathnames.sort(comparePathnamePairs);
51
- return sortedPathnames;
52
- }
53
7
  function getInternalTemplate(pathnames, pathname, locale) {
54
- const sortedPathnames = getSortedPathnames(Object.keys(pathnames));
8
+ const sortedPathnames = utils.getSortedPathnames(Object.keys(pathnames));
55
9
 
56
10
  // Try to find a localized pathname that matches
57
11
  for (const internalPathname of sortedPathnames) {
@@ -81,7 +35,7 @@ function getInternalTemplate(pathnames, pathname, locale) {
81
35
  }
82
36
 
83
37
  // Try to find an internal pathname that matches (this can be the case
84
- // if all localized pathnames are different from the internal pathnames).
38
+ // if all localized pathnames are different from the internal pathnames)
85
39
  for (const internalPathname of Object.keys(pathnames)) {
86
40
  if (utils.matchesPathname(internalPathname, pathname)) {
87
41
  return [undefined, internalPathname];
@@ -232,7 +186,6 @@ function getLocaleAsPrefix(locale) {
232
186
  }
233
187
 
234
188
  exports.applyBasePath = applyBasePath;
235
- exports.comparePathnamePairs = comparePathnamePairs;
236
189
  exports.formatPathname = formatPathname;
237
190
  exports.formatPathnameTemplate = formatPathnameTemplate;
238
191
  exports.formatTemplatePathname = formatTemplatePathname;
@@ -244,6 +197,5 @@ exports.getLocalePrefixes = getLocalePrefixes;
244
197
  exports.getNormalizedPathname = getNormalizedPathname;
245
198
  exports.getPathnameMatch = getPathnameMatch;
246
199
  exports.getRouteParams = getRouteParams;
247
- exports.getSortedPathnames = getSortedPathnames;
248
200
  exports.isLocaleSupportedOnDomain = isLocaleSupportedOnDomain;
249
201
  exports.normalizeTrailingSlash = normalizeTrailingSlash;
@@ -125,11 +125,7 @@ function createLocalizedPathnamesNavigation(input) {
125
125
  const locale = useTypedLocale();
126
126
 
127
127
  // @ts-expect-error -- Mirror the behavior from Next.js, where `null` is returned when `usePathname` is used outside of Next, but the types indicate that a string is always returned.
128
- return pathname ? utils.getRoute({
129
- pathname,
130
- locale,
131
- pathnames: config$1.pathnames
132
- }) : pathname;
128
+ return pathname ? utils.getRoute(locale, pathname, config$1.pathnames) : pathname;
133
129
  }
134
130
  function getPathname(_ref2) {
135
131
  let {
@@ -84,23 +84,23 @@ function compileLocalizedPathname(_ref) {
84
84
  return result;
85
85
  }
86
86
  }
87
- function getRoute(_ref3) {
88
- var _Object$entries$find;
89
- let {
90
- locale,
91
- pathname,
92
- pathnames
93
- } = _ref3;
87
+ function getRoute(locale, pathname, pathnames) {
88
+ const sortedPathnames = utils.getSortedPathnames(Object.keys(pathnames));
94
89
  const decoded = decodeURI(pathname);
95
- let template = (_Object$entries$find = Object.entries(pathnames).find(_ref4 => {
96
- let [, routePath] = _ref4;
97
- const routePathname = typeof routePath !== 'string' ? routePath[locale] : routePath;
98
- return utils.matchesPathname(routePathname, decoded);
99
- })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
100
- if (!template) {
101
- template = pathname;
90
+ for (const internalPathname of sortedPathnames) {
91
+ const localizedPathnamesOrPathname = pathnames[internalPathname];
92
+ if (typeof localizedPathnamesOrPathname === 'string') {
93
+ const localizedPathname = localizedPathnamesOrPathname;
94
+ if (utils.matchesPathname(localizedPathname, decoded)) {
95
+ return internalPathname;
96
+ }
97
+ } else {
98
+ if (utils.matchesPathname(localizedPathnamesOrPathname[locale], decoded)) {
99
+ return internalPathname;
100
+ }
101
+ }
102
102
  }
103
- return template;
103
+ return pathname;
104
104
  }
105
105
  function getBasePath(pathname) {
106
106
  let windowPathname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.pathname;
@@ -85,8 +85,54 @@ function templateToRegex(template) {
85
85
  .replace(/\[([^\]]+)\]/g, '([^/]+)');
86
86
  return new RegExp("^".concat(regexPattern, "$"));
87
87
  }
88
+ function isOptionalCatchAllSegment(pathname) {
89
+ return pathname.includes('[[...');
90
+ }
91
+ function isCatchAllSegment(pathname) {
92
+ return pathname.includes('[...');
93
+ }
94
+ function isDynamicSegment(pathname) {
95
+ return pathname.includes('[');
96
+ }
97
+ function comparePathnamePairs(a, b) {
98
+ const pathA = a.split('/');
99
+ const pathB = b.split('/');
100
+ const maxLength = Math.max(pathA.length, pathB.length);
101
+ for (let i = 0; i < maxLength; i++) {
102
+ const segmentA = pathA[i];
103
+ const segmentB = pathB[i];
104
+
105
+ // If one of the paths ends, prioritize the shorter path
106
+ if (!segmentA && segmentB) return -1;
107
+ if (segmentA && !segmentB) return 1;
108
+
109
+ // Prioritize static segments over dynamic segments
110
+ if (!isDynamicSegment(segmentA) && isDynamicSegment(segmentB)) return -1;
111
+ if (isDynamicSegment(segmentA) && !isDynamicSegment(segmentB)) return 1;
112
+
113
+ // Prioritize non-catch-all segments over catch-all segments
114
+ if (!isCatchAllSegment(segmentA) && isCatchAllSegment(segmentB)) return -1;
115
+ if (isCatchAllSegment(segmentA) && !isCatchAllSegment(segmentB)) return 1;
116
+
117
+ // Prioritize non-optional catch-all segments over optional catch-all segments
118
+ if (!isOptionalCatchAllSegment(segmentA) && isOptionalCatchAllSegment(segmentB)) {
119
+ return -1;
120
+ }
121
+ if (isOptionalCatchAllSegment(segmentA) && !isOptionalCatchAllSegment(segmentB)) {
122
+ return 1;
123
+ }
124
+ if (segmentA === segmentB) continue;
125
+ }
126
+
127
+ // Both pathnames are completely static
128
+ return 0;
129
+ }
130
+ function getSortedPathnames(pathnames) {
131
+ return pathnames.sort(comparePathnamePairs);
132
+ }
88
133
 
89
134
  exports.getLocalePrefix = getLocalePrefix;
135
+ exports.getSortedPathnames = getSortedPathnames;
90
136
  exports.hasPathnamePrefixed = hasPathnamePrefixed;
91
137
  exports.isLocalHref = isLocalHref;
92
138
  exports.isLocalizableHref = isLocalizableHref;
@@ -1 +1 @@
1
- import{matchesPathname as t,getLocalePrefix as n,templateToRegex as e,prefixPathname as r}from"../shared/utils.js";function o(t){return t.includes("[[...")}function i(t){return t.includes("[...")}function c(t){return t.includes("[")}function u(t,n){const e=t.split("/"),r=n.split("/"),u=Math.max(e.length,r.length);for(let t=0;t<u;t++){const n=e[t],u=r[t];if(!n&&u)return-1;if(n&&!u)return 1;if(!c(n)&&c(u))return-1;if(c(n)&&!c(u))return 1;if(!i(n)&&i(u))return-1;if(i(n)&&!i(u))return 1;if(!o(n)&&o(u))return-1;if(o(n)&&!o(u))return 1}return 0}function l(t){return t.sort(u)}function f(n,e,r){const o=l(Object.keys(n));for(const i of o){const o=n[i];if("string"==typeof o){if(t(o,e))return[void 0,i]}else{const n=Object.entries(o),c=n.findIndex((t=>{let[n]=t;return n===r}));c>0&&n.unshift(n.splice(c,1)[0]);for(const[r,o]of n)if(t(o,e))return[r,i]}}for(const r of Object.keys(n))if(t(r,e))return[void 0,r];return[void 0,void 0]}function s(t,n,e,r){let o="";return o+=g(e,p(n,t)),o=w(o),o}function a(t,n,e){t.endsWith("/")||(t+="/");const r=d(n,e),o=new RegExp("^(".concat(r.map((t=>{let[,n]=t;return n.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),i=t.match(o);let c=i?"/"+i[2]:t;return"/"!==c&&(c=w(c)),c}function d(t,e){return t.map((t=>[t,n(t,e)]))}function h(t,n,e){const r=d(n,e);for(const[n,e]of r){let r,o;if(t===e||t.startsWith(e+"/"))r=o=!0;else{const n=t.toLowerCase(),i=e.toLowerCase();(n===i||n.startsWith(i+"/"))&&(r=!1,o=!0)}if(o)return{locale:n,prefix:e,matchedPrefix:t.slice(0,e.length),exact:r}}}function p(t,n){const r=e(t).exec(n);if(!r)return;const o={};for(let n=1;n<r.length;n++){var i;const e=null===(i=t.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[n-1].replace(/[[\]]/g,"");e&&(o[e]=r[n])}return o}function g(t,n){if(!n)return t;let e=t=t.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(n).forEach((t=>{let[n,r]=t;e=e.replace("[".concat(n,"]"),r)})),e}function v(t,n,e){let o=t;return n&&(o=r(n,o)),e&&(o+=e),o}function x(t){var n,e;return null!==(n=null!==(e=t.get("x-forwarded-host"))&&void 0!==e?e:t.get("host"))&&void 0!==n?n:void 0}function m(t,n){return n.defaultLocale===t||!n.locales||n.locales.includes(t)}function j(t,n,e){let r;return t&&m(n,t)&&(r=t),r||(r=e.find((t=>t.defaultLocale===n))),r||(r=e.find((t=>null!=t.locales&&t.locales.includes(n)))),r||null!=(null==t?void 0:t.locales)||(r=t),r||(r=e.find((t=>!t.locales))),r}function b(t,n){return w(n+t)}function w(t){return"/"!==t&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function L(t){return"/".concat(t)}export{b as applyBasePath,u as comparePathnamePairs,v as formatPathname,g as formatPathnameTemplate,s as formatTemplatePathname,j as getBestMatchingDomain,x as getHost,f as getInternalTemplate,L as getLocaleAsPrefix,d as getLocalePrefixes,a as getNormalizedPathname,h as getPathnameMatch,p as getRouteParams,l as getSortedPathnames,m as isLocaleSupportedOnDomain,w as normalizeTrailingSlash};
1
+ import{getSortedPathnames as t,matchesPathname as e,getLocalePrefix as n,templateToRegex as o,prefixPathname as r}from"../shared/utils.js";function c(n,o,r){const c=t(Object.keys(n));for(const t of c){const c=n[t];if("string"==typeof c){if(e(c,o))return[void 0,t]}else{const n=Object.entries(c),l=n.findIndex((t=>{let[e]=t;return e===r}));l>0&&n.unshift(n.splice(l,1)[0]);for(const[r,c]of n)if(e(c,o))return[r,t]}}for(const t of Object.keys(n))if(e(t,o))return[void 0,t];return[void 0,void 0]}function l(t,e,n,o){let r="";return r+=a(n,f(e,t)),r=x(r),r}function i(t,e,n){t.endsWith("/")||(t+="/");const o=u(e,n),r=new RegExp("^(".concat(o.map((t=>{let[,e]=t;return e.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),c=t.match(r);let l=c?"/"+c[2]:t;return"/"!==l&&(l=x(l)),l}function u(t,e){return t.map((t=>[t,n(t,e)]))}function s(t,e,n){const o=u(e,n);for(const[e,n]of o){let o,r;if(t===n||t.startsWith(n+"/"))o=r=!0;else{const e=t.toLowerCase(),c=n.toLowerCase();(e===c||e.startsWith(c+"/"))&&(o=!1,r=!0)}if(r)return{locale:e,prefix:n,matchedPrefix:t.slice(0,n.length),exact:o}}}function f(t,e){const n=o(t).exec(e);if(!n)return;const r={};for(let e=1;e<n.length;e++){var c;const o=null===(c=t.match(/\[([^\]]+)\]/g))||void 0===c?void 0:c[e-1].replace(/[[\]]/g,"");o&&(r[o]=n[e])}return r}function a(t,e){if(!e)return t;let n=t=t.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(e).forEach((t=>{let[e,o]=t;n=n.replace("[".concat(e,"]"),o)})),n}function d(t,e,n){let o=t;return e&&(o=r(e,o)),n&&(o+=n),o}function h(t){var e,n;return null!==(e=null!==(n=t.get("x-forwarded-host"))&&void 0!==n?n:t.get("host"))&&void 0!==e?e:void 0}function p(t,e){return e.defaultLocale===t||!e.locales||e.locales.includes(t)}function v(t,e,n){let o;return t&&p(e,t)&&(o=t),o||(o=n.find((t=>t.defaultLocale===e))),o||(o=n.find((t=>null!=t.locales&&t.locales.includes(e)))),o||null!=(null==t?void 0:t.locales)||(o=t),o||(o=n.find((t=>!t.locales))),o}function g(t,e){return x(e+t)}function x(t){return"/"!==t&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function m(t){return"/".concat(t)}export{g as applyBasePath,d as formatPathname,a as formatPathnameTemplate,l as formatTemplatePathname,v as getBestMatchingDomain,h as getHost,c as getInternalTemplate,m as getLocaleAsPrefix,u as getLocalePrefixes,i as getNormalizedPathname,s as getPathnameMatch,f as getRouteParams,p as isLocaleSupportedOnDomain,x as normalizeTrailingSlash};
@@ -1 +1 @@
1
- import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o}from"react";import t from"../../react-client/useLocale.js";import{receiveLocalizedNavigationRoutingConfig as a}from"../shared/config.js";import{getRoute as n,compileLocalizedPathname as l,normalizeNameOrNameWithParams as c}from"../shared/utils.js";import i from"./ClientLink.js";import{clientRedirect as s,clientPermanentRedirect as f}from"./redirects.js";import u from"./useBasePathname.js";import m from"./useBaseRouter.js";function h(h){const p=a(h);function d(){const e=t();if(!p.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `i18n.ts`.'));return e}function v(o,t){let{href:a,locale:n,...c}=o;const s=d(),f=n||s;return r.createElement(i,e({ref:t,href:l({locale:f,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:p.pathnames}),locale:n,localePrefix:p.localePrefix},c))}const P=o(v);function x(e){let{href:r,locale:o}=e;return l({...c(r),locale:o,pathnames:p.pathnames})}return P.displayName="Link",{Link:P,redirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),a=1;a<o;a++)t[a-1]=arguments[a];return s({pathname:r,localePrefix:p.localePrefix},...t)},permanentRedirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),a=1;a<o;a++)t[a-1]=arguments[a];return f({pathname:r,localePrefix:p.localePrefix},...t)},usePathname:function(){const e=u(p.localePrefix),r=d();return e?n({pathname:e,locale:r,pathnames:p.pathnames}):e},useRouter:function(){const e=m(p.localePrefix),r=d();return{...e,push(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:x}}export{h as default};
1
+ import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o}from"react";import t from"../../react-client/useLocale.js";import{receiveLocalizedNavigationRoutingConfig as n}from"../shared/config.js";import{getRoute as a,compileLocalizedPathname as l,normalizeNameOrNameWithParams as c}from"../shared/utils.js";import i from"./ClientLink.js";import{clientRedirect as s,clientPermanentRedirect as f}from"./redirects.js";import u from"./useBasePathname.js";import m from"./useBaseRouter.js";function h(h){const p=n(h);function d(){const e=t();if(!p.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `i18n.ts`.'));return e}function v(o,t){let{href:n,locale:a,...c}=o;const s=d(),f=a||s;return r.createElement(i,e({ref:t,href:l({locale:f,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:p.pathnames}),locale:a,localePrefix:p.localePrefix},c))}const P=o(v);function x(e){let{href:r,locale:o}=e;return l({...c(r),locale:o,pathnames:p.pathnames})}return P.displayName="Link",{Link:P,redirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),n=1;n<o;n++)t[n-1]=arguments[n];return s({pathname:r,localePrefix:p.localePrefix},...t)},permanentRedirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),n=1;n<o;n++)t[n-1]=arguments[n];return f({pathname:r,localePrefix:p.localePrefix},...t)},usePathname:function(){const e=u(p.localePrefix),r=d();return e?a(r,e,p.pathnames):e},useRouter:function(){const e=m(p.localePrefix),r=d();return{...e,push(o){for(var t,n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=a[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...a)},replace(o){for(var t,n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=a[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...a)},prefetch(o){for(var t,n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=a[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...a)}}},getPathname:x}}export{h as default};
@@ -1 +1 @@
1
- import{matchesPathname as t}from"../../shared/utils.js";function n(t){return"string"==typeof t?{pathname:t}:t}function e(t){function n(t){return String(t)}const e=new URLSearchParams;for(const[r,a]of Object.entries(t))Array.isArray(a)?a.forEach((t=>{e.append(r,n(t))})):e.set(r,n(a));return"?"+e.toString()}function r(t){let{pathname:n,locale:r,params:a,pathnames:o,query:i}=t;function c(t){let n=o[t];return n||(n=t),n}function s(t){const n="string"==typeof t?t:t[r];let o=n;if(a&&Object.entries(a).forEach((t=>{let[n,e]=t;o=Array.isArray(e)?o.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),e.map((t=>String(t))).join("/")):o.replace("[".concat(n,"]"),String(e))})),o.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(a)));return i&&(o+=e(i)),o}if("string"==typeof n){return s(c(n))}{const{pathname:t,...e}=n;return{...e,pathname:s(c(t))}}}function a(n){var e;let{locale:r,pathname:a,pathnames:o}=n;const i=decodeURI(a);let c=null===(e=Object.entries(o).find((n=>{let[,e]=n;const a="string"!=typeof e?e[r]:e;return t(a,i)})))||void 0===e?void 0:e[0];return c||(c=a),c}function o(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===t?n:n.replace(t,"")}export{r as compileLocalizedPathname,o as getBasePath,a as getRoute,n as normalizeNameOrNameWithParams,e as serializeSearchParams};
1
+ import{getSortedPathnames as t,matchesPathname as n}from"../../shared/utils.js";function r(t){return"string"==typeof t?{pathname:t}:t}function e(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 o(t){let{pathname:n,locale:r,params:o,pathnames:a,query:c}=t;function i(t){let n=a[t];return n||(n=t),n}function s(t){const n="string"==typeof t?t:t[r];let a=n;if(o&&Object.entries(o).forEach((t=>{let[n,r]=t;a=Array.isArray(r)?a.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),r.map((t=>String(t))).join("/")):a.replace("[".concat(n,"]"),String(r))})),a.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(o)));return c&&(a+=e(c)),a}if("string"==typeof n){return s(i(n))}{const{pathname:t,...r}=n;return{...r,pathname:s(i(t))}}}function a(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 c(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===t?n:n.replace(t,"")}export{o as compileLocalizedPathname,c as getBasePath,a as getRoute,r as normalizeNameOrNameWithParams,e as serializeSearchParams};
@@ -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){return n(e)&&!t(e)}function r(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,u=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!e(t))return t;const l=n!==r,a=i(c,u);return(l||a)&&null!=c?o(t,c):t}function o(t,n){let e;return"string"==typeof t?e=c(n,t):(e={...t},t.pathname&&(e.pathname=c(n,t.pathname))),e}function u(t,n){return t.replace(new RegExp("^".concat(n)),"")||"/"}function c(t,n){let e=t;return/^\/(\?.*)?$/.test(n)&&(n=n.slice(1)),e+=n,e}function i(t,n){return n===t||n.startsWith("".concat(t,"/"))}function l(t,n){return f(t).test(n)}function a(t,n){var e;return"never"!==n.mode&&(null===(e=n.prefixes)||void 0===e?void 0:e[t])||"/"+t}function f(t){const n=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(n,"$"))}export{a as getLocalePrefix,i as hasPathnamePrefixed,n as isLocalHref,e as isLocalizableHref,t as isRelativeHref,r as localizeHref,l as matchesPathname,o as prefixHref,c as prefixPathname,f as templateToRegex,u as unprefixPathname};
1
+ function n(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}function t(n){if("object"==typeof n)return null==n.host&&null==n.hostname;return!/^[a-z]+:/i.test(n)}function e(e){return t(e)&&!n(e)}function r(n,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if(!e(n))return n;const f=t!==r,l=c(o,i);return(f||l)&&null!=o?u(n,o):n}function u(n,t){let e;return"string"==typeof n?e=o(t,n):(e={...n},n.pathname&&(e.pathname=o(t,n.pathname))),e}function i(n,t){return n.replace(new RegExp("^".concat(t)),"")||"/"}function o(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function c(n,t){return t===n||t.startsWith("".concat(n,"/"))}function f(n,t){return s(n).test(t)}function l(n,t){var e;return"never"!==t.mode&&(null===(e=t.prefixes)||void 0===e?void 0:e[n])||"/"+n}function s(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function a(n){return n.includes("[[...")}function p(n){return n.includes("[...")}function h(n){return n.includes("[")}function g(n,t){const e=n.split("/"),r=t.split("/"),u=Math.max(e.length,r.length);for(let n=0;n<u;n++){const t=e[n],u=r[n];if(!t&&u)return-1;if(t&&!u)return 1;if(!h(t)&&h(u))return-1;if(h(t)&&!h(u))return 1;if(!p(t)&&p(u))return-1;if(p(t)&&!p(u))return 1;if(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1}return 0}function d(n){return n.sort(g)}export{l as getLocalePrefix,d as getSortedPathnames,c as hasPathnamePrefixed,t as isLocalHref,e as isLocalizableHref,n as isRelativeHref,r as localizeHref,f as matchesPathname,u as prefixHref,o as prefixPathname,s as templateToRegex,i as unprefixPathname};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.includes("[[...")}function n(e){return e.includes("[...")}function r(e){return e.includes("[")}function o(e,o){const a=e.split("/"),i=o.split("/"),s=Math.max(a.length,i.length);for(let e=0;e<s;e++){const o=a[e],s=i[e];if(!o&&s)return-1;if(o&&!s)return 1;if(!r(o)&&r(s))return-1;if(r(o)&&!r(s))return 1;if(!n(o)&&n(s))return-1;if(n(o)&&!n(s))return 1;if(!t(o)&&t(s))return-1;if(t(o)&&!t(s))return 1}return 0}function a(e){return e.sort(o)}function i(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}function s(t,n){const r=e.templateToRegex(t).exec(n);if(!r)return;const o={};for(let e=1;e<r.length;e++){var a;const n=null===(a=t.match(/\[([^\]]+)\]/g))||void 0===a?void 0:a[e-1].replace(/[[\]]/g,"");n&&(o[n]=r[e])}return o}function c(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 l(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function u(e){return"/"!==e&&e.endsWith("/")&&(e=e.slice(0,-1)),e}exports.applyBasePath=function(e,t){return u(t+e)},exports.comparePathnamePairs=o,exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=c,exports.formatTemplatePathname=function(e,t,n,r){let o="";return o+=c(n,s(t,e)),o=u(o),o},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&l(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=a(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),i=t.findIndex((e=>{let[t]=e;return t===r}));i>0&&t.unshift(t.splice(i,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=i,exports.getNormalizedPathname=function(e,t,n){e.endsWith("/")||(e+="/");const r=i(t,n),o=new RegExp("^(".concat(r.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),a=e.match(o);let s=a?"/"+a[2]:e;return"/"!==s&&(s=u(s)),s},exports.getPathnameMatch=function(e,t,n){const r=i(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(),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=s,exports.getSortedPathnames=a,exports.isLocaleSupportedOnDomain=l,exports.normalizeTrailingSlash=u;
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 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 o(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 r(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function a(e){return"/"!==e&&e.endsWith("/")&&(e=e.slice(0,-1)),e}exports.applyBasePath=function(e,t){return a(t+e)},exports.formatPathname=function(t,n,o){let r=t;return n&&(r=e.prefixPathname(n,r)),o&&(r+=o),r},exports.formatPathnameTemplate=o,exports.formatTemplatePathname=function(e,t,r,s){let c="";return c+=o(r,n(t,e)),c=a(c),c},exports.getBestMatchingDomain=function(e,t,n){let o;return e&&r(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.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,o){const r=e.getSortedPathnames(Object.keys(t));for(const a of r){const r=t[a];if("string"==typeof r){const t=r;if(e.matchesPathname(t,n))return[void 0,a]}else{const t=Object.entries(r),s=t.findIndex((e=>{let[t]=e;return t===o}));s>0&&t.unshift(t.splice(s,1)[0]);for(const[o,r]of t)if(e.matchesPathname(r,n))return[o,a]}}for(const o of Object.keys(t))if(e.matchesPathname(o,n))return[void 0,o];return[void 0,void 0]},exports.getLocaleAsPrefix=function(e){return"/".concat(e)},exports.getLocalePrefixes=t,exports.getNormalizedPathname=function(e,n,o){e.endsWith("/")||(e+="/");const r=t(n,o),s=new RegExp("^(".concat(r.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),c=e.match(s);let l=c?"/"+c[2]:e;return"/"!==l&&(l=a(l)),l},exports.getPathnameMatch=function(e,n,o){const r=t(n,o);for(const[t,n]of r){let o,r;if(e===n||e.startsWith(n+"/"))o=r=!0;else{const t=e.toLowerCase(),a=n.toLowerCase();(t===a||t.startsWith(a+"/"))&&(o=!1,r=!0)}if(r)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:o}}},exports.getRouteParams=n,exports.isLocaleSupportedOnDomain=r,exports.normalizeTrailingSlash=a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),t=require("../shared/config.js"),l=require("../shared/utils.js"),n=require("./ClientLink.js"),o=require("./redirects.js"),c=require("./useBasePathname.js"),i=require("./useBaseRouter.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=function(u){const f=t.receiveLocalizedNavigationRoutingConfig(u);function h(){const e=a.default();if(!f.locales.includes(e))throw new Error(void 0);return e}function d(r,a){let{href:t,locale:o,...c}=r;const i=h(),u=o||i;return s.default.createElement(n.default,e.extends({ref:a,href:l.compileLocalizedPathname({locale:u,pathname:t,params:"object"==typeof t?t.params:void 0,pathnames:f.pathnames}),locale:o,localePrefix:f.localePrefix},c))}const p=r.forwardRef(d);function m(e){let{href:r,locale:a}=e;return l.compileLocalizedPathname({...l.normalizeNameOrNameWithParams(r),locale:a,pathnames:f.pathnames})}return p.displayName="Link",{Link:p,redirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientRedirect({pathname:r,localePrefix:f.localePrefix},...t)},permanentRedirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientPermanentRedirect({pathname:r,localePrefix:f.localePrefix},...t)},usePathname:function(){const e=c.default(f.localePrefix),r=h();return e?l.getRoute({pathname:e,locale:r,pathnames:f.pathnames}):e},useRouter:function(){const e=i.default(f.localePrefix),r=h();return{...e,push(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:m}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),t=require("../shared/config.js"),l=require("../shared/utils.js"),n=require("./ClientLink.js"),o=require("./redirects.js"),c=require("./useBasePathname.js"),i=require("./useBaseRouter.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=function(u){const f=t.receiveLocalizedNavigationRoutingConfig(u);function h(){const e=a.default();if(!f.locales.includes(e))throw new Error(void 0);return e}function d(r,a){let{href:t,locale:o,...c}=r;const i=h(),u=o||i;return s.default.createElement(n.default,e.extends({ref:a,href:l.compileLocalizedPathname({locale:u,pathname:t,params:"object"==typeof t?t.params:void 0,pathnames:f.pathnames}),locale:o,localePrefix:f.localePrefix},c))}const p=r.forwardRef(d);function m(e){let{href:r,locale:a}=e;return l.compileLocalizedPathname({...l.normalizeNameOrNameWithParams(r),locale:a,pathnames:f.pathnames})}return p.displayName="Link",{Link:p,redirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientRedirect({pathname:r,localePrefix:f.localePrefix},...t)},permanentRedirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientPermanentRedirect({pathname:r,localePrefix:f.localePrefix},...t)},usePathname:function(){const e=c.default(f.localePrefix),r=h();return e?l.getRoute(r,e,f.pathnames):e},useRouter:function(){const e=i.default(f.localePrefix),r=h();return{...e,push(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:m}};
@@ -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(e){let{pathname:r,locale:n,params:a,pathnames:o,query:i}=e;function c(e){let t=o[e];return t||(t=e),t}function s(e){let r="string"==typeof e?e:e[n];return a&&Object.entries(a).forEach((e=>{let[t,n]=e;r=Array.isArray(n)?r.replace(new RegExp("(\\[)?\\[...".concat(t,"\\](\\])?"),"g"),n.map((e=>String(e))).join("/")):r.replace("[".concat(t,"]"),String(n))})),i&&(r+=t(i)),r}if("string"==typeof r){return s(c(r))}{const{pathname:e,...t}=r;return{...t,pathname:s(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){var r;let{locale:n,pathname:a,pathnames:o}=t;const i=decodeURI(a);let c=null===(r=Object.entries(o).find((t=>{let[,r]=t;const a="string"!=typeof r?r[n]:r;return e.matchesPathname(a,i)})))||void 0===r?void 0:r[0];return c||(c=a),c},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
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(e){let{pathname:r,locale:n,params:a,pathnames:o,query:s}=e;function c(e){let t=o[e];return t||(t=e),t}function i(e){let r="string"==typeof e?e:e[n];return a&&Object.entries(a).forEach((e=>{let[t,n]=e;r=Array.isArray(n)?r.replace(new RegExp("(\\[)?\\[...".concat(t,"\\](\\])?"),"g"),n.map((e=>String(e))).join("/")):r.replace("[".concat(t,"]"),String(n))})),s&&(r+=t(s)),r}if("string"==typeof r){return i(c(r))}{const{pathname:e,...t}=r;return{...t,pathname:i(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;
@@ -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(n){return t(n)&&!e(n)}function r(e,t){let n;return"string"==typeof e?n=o(t,e):(n={...e},e.pathname&&(n.pathname=o(t,e.pathname))),n}function o(e,t){let n=e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function a(e,t){return t===e||t.startsWith("".concat(e,"/"))}function i(e){const t=e.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocalePrefix=function(e,t){var n;return"never"!==t.mode&&(null===(n=t.prefixes)||void 0===n?void 0:n[e])||"/"+e},exports.hasPathnamePrefixed=a,exports.isLocalHref=t,exports.isLocalizableHref=n,exports.isRelativeHref=e,exports.localizeHref=function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!n(e))return e;const c=t!==o,u=a(s,i);return(c||u)&&null!=s?r(e,s):e},exports.matchesPathname=function(e,t){return i(e).test(t)},exports.prefixHref=r,exports.prefixPathname=o,exports.templateToRegex=i,exports.unprefixPathname=function(e,t){return e.replace(new RegExp("^".concat(t)),"")||"/"};
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(n){return t(n)&&!e(n)}function r(e,t){let n;return"string"==typeof e?n=o(t,e):(n={...e},e.pathname&&(n.pathname=o(t,e.pathname))),n}function o(e,t){let n=e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function i(e,t){return t===e||t.startsWith("".concat(e,"/"))}function u(e){const t=e.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function s(e){return e.includes("[[...")}function c(e){return e.includes("[...")}function a(e){return e.includes("[")}function f(e,t){const n=e.split("/"),r=t.split("/"),o=Math.max(n.length,r.length);for(let e=0;e<o;e++){const t=n[e],o=r[e];if(!t&&o)return-1;if(t&&!o)return 1;if(!a(t)&&a(o))return-1;if(a(t)&&!a(o))return 1;if(!c(t)&&c(o))return-1;if(c(t)&&!c(o))return 1;if(!s(t)&&s(o))return-1;if(s(t)&&!s(o))return 1}return 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocalePrefix=function(e,t){var n;return"never"!==t.mode&&(null===(n=t.prefixes)||void 0===n?void 0:n[e])||"/"+e},exports.getSortedPathnames=function(e){return e.sort(f)},exports.hasPathnamePrefixed=i,exports.isLocalHref=t,exports.isLocalizableHref=n,exports.isRelativeHref=e,exports.localizeHref=function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,u=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!n(e))return e;const c=t!==o,a=i(s,u);return(c||a)&&null!=s?r(e,s):e},exports.matchesPathname=function(e,t){return u(e).test(t)},exports.prefixHref=r,exports.prefixPathname=o,exports.templateToRegex=u,exports.unprefixPathname=function(e,t){return e.replace(new RegExp("^".concat(t)),"")||"/"};
@@ -1,7 +1,5 @@
1
1
  import { Locales, LocalePrefixConfigVerbose, DomainConfig, Pathnames } from '../routing/types';
2
2
  export declare function getFirstPathnameSegment(pathname: string): string;
3
- export declare function comparePathnamePairs(a: string, b: string): number;
4
- export declare function getSortedPathnames(pathnames: Array<string>): string[];
5
3
  export declare function getInternalTemplate<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(pathnames: AppPathnames, pathname: string, locale: AppLocales[number]): [AppLocales[number] | undefined, keyof AppPathnames | undefined];
6
4
  export declare function formatTemplatePathname(sourcePathname: string, sourceTemplate: string, targetTemplate: string, prefix?: string): string;
7
5
  /**
@@ -43,10 +43,6 @@ export declare function compileLocalizedPathname<AppLocales extends Locales, Pat
43
43
  pathnames: Pathnames<AppLocales>;
44
44
  query?: Record<string, SearchParamValue>;
45
45
  }): UrlObject;
46
- export declare function getRoute<AppLocales extends Locales>({ locale, pathname, pathnames }: {
47
- locale: AppLocales[number];
48
- pathname: string;
49
- pathnames: Pathnames<AppLocales>;
50
- }): string;
46
+ export declare function getRoute<AppLocales extends Locales>(locale: AppLocales[number], pathname: string, pathnames: Pathnames<AppLocales>): keyof Pathnames<AppLocales>;
51
47
  export declare function getBasePath(pathname: string, windowPathname?: string): string;
52
48
  export {};
@@ -21,4 +21,5 @@ template: string,
21
21
  pathname: string): boolean;
22
22
  export declare function getLocalePrefix<AppLocales extends Locales>(locale: AppLocales[number], localePrefix: LocalePrefixConfigVerbose<AppLocales>): string;
23
23
  export declare function templateToRegex(template: string): RegExp;
24
+ export declare function getSortedPathnames(pathnames: Array<string>): string[];
24
25
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.15.2",
3
+ "version": "3.15.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.15.2"
90
+ "use-intl": "^3.15.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.235 KB"
107
+ "limit": "3.355 KB"
108
108
  },
109
109
  {
110
110
  "path": "dist/production/navigation.react-server.js",
111
- "limit": "17.84 KB"
111
+ "limit": "17.975 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": "e83042b85dbe84d18d0c9d31fe1ecef2cb9bf158"
130
+ "gitHead": "5596ae873df9b558a564f7b73da64105da7fb2bb"
131
131
  }