next-intl 3.17.0 → 3.17.2

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.
@@ -16,7 +16,11 @@ function createMiddleware(input) {
16
16
  return function middleware(request) {
17
17
  var _config$domains;
18
18
  // Resolve potential foreign symbols (e.g. /ja/%E7%B4%84 → /ja/約))
19
- const externalPathname = decodeURI(request.nextUrl.pathname);
19
+ const unsafeExternalPathname = decodeURI(request.nextUrl.pathname);
20
+
21
+ // Sanitize malicious URIs to prevent open redirect attacks due to
22
+ // decodeURI doesn't escape encoded backslashes ('%5C' & '%5c')
23
+ const externalPathname = utils.sanitizePathname(unsafeExternalPathname);
20
24
  const {
21
25
  domain,
22
26
  locale
@@ -184,6 +184,12 @@ function applyBasePath(pathname, basePath) {
184
184
  function getLocaleAsPrefix(locale) {
185
185
  return "/".concat(locale);
186
186
  }
187
+ function sanitizePathname(pathname) {
188
+ // Sanitize malicious URIs, e.g.:
189
+ // '/en/\\example.org → /en/%5C%5Cexample.org'
190
+ // '/en////example.org → /en/example.org'
191
+ return pathname.replace(/\\/g, '%5C').replace(/\/+/g, '/');
192
+ }
187
193
 
188
194
  exports.applyBasePath = applyBasePath;
189
195
  exports.formatPathname = formatPathname;
@@ -198,3 +204,4 @@ exports.getNormalizedPathname = getNormalizedPathname;
198
204
  exports.getPathnameMatch = getPathnameMatch;
199
205
  exports.getRouteParams = getRouteParams;
200
206
  exports.isLocaleSupportedOnDomain = isLocaleSupportedOnDomain;
207
+ exports.sanitizePathname = sanitizePathname;
@@ -83,7 +83,7 @@ function createLocalizedPathnamesNavigation(input) {
83
83
  function useRouter() {
84
84
  const baseRouter = useBaseRouter.default(config$1.localePrefix);
85
85
  const defaultLocale = useTypedLocale();
86
- return {
86
+ return React.useMemo(() => ({
87
87
  ...baseRouter,
88
88
  push(href) {
89
89
  var _args$;
@@ -118,14 +118,14 @@ function createLocalizedPathnamesNavigation(input) {
118
118
  });
119
119
  return baseRouter.prefetch(resolvedHref, ...args);
120
120
  }
121
- };
121
+ }), [baseRouter, defaultLocale]);
122
122
  }
123
123
  function usePathname() {
124
124
  const pathname = useBasePathname.default(config$1.localePrefix);
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(locale, pathname, config$1.pathnames) : pathname;
128
+ return React.useMemo(() => pathname ? utils.getRoute(locale, pathname, config$1.pathnames) : pathname, [locale, pathname]);
129
129
  }
130
130
  function getPathname(_ref2) {
131
131
  let {
@@ -1 +1 @@
1
- import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,normalizeTrailingSlash as r,getLocalePrefix as t}from"../shared/utils.js";import{receiveConfig as a}from"./config.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{isLocaleSupportedOnDomain as c,getNormalizedPathname as d,getPathnameMatch as f,getInternalTemplate as m,formatTemplatePathname as h,formatPathname as x,getBestMatchingDomain as u,applyBasePath as p,getLocaleAsPrefix as v}from"./utils.js";function U(U){const P=a(U);return function(a){var U;const g=decodeURI(a.nextUrl.pathname),{domain:L,locale:j}=s(P,a.headers,a.cookies,g),w=L?L.defaultLocale===j:j===P.defaultLocale,k=(null===(U=P.domains)||void 0===U?void 0:U.filter((e=>c(j,e))))||[],b=null!=P.domains&&!L;function y(l){const r=new URL(l,a.url);a.nextUrl.basePath&&(r.pathname=p(r.pathname,a.nextUrl.basePath));const t=new Headers(a.headers);return t.set(o,j),e.rewrite(r,{request:{headers:t}})}function R(o,l){const t=new URL(r(o),a.url);if(k.length>0&&!l){const e=u(L,j,k);e&&(l=e.domain,e.defaultLocale===j&&"as-needed"===P.localePrefix.mode&&(t.pathname=d(t.pathname,P.locales,P.localePrefix)))}var n,s;l&&(t.host=l,a.headers.get("x-forwarded-host")&&(t.protocol=null!==(n=a.headers.get("x-forwarded-proto"))&&void 0!==n?n:a.nextUrl.protocol,t.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(t.pathname=p(t.pathname,a.nextUrl.basePath)),e.redirect(t.toString())}const q=d(g,P.locales,P.localePrefix),H=f(g,P.locales,P.localePrefix),z=null!=H,A="never"===P.localePrefix.mode||w&&"as-needed"===P.localePrefix.mode;let C,D,I=q;if(P.pathnames){let e;if([e,D]=m(P.pathnames,q,j),D){const o=P.pathnames[D],r="string"==typeof o?o:o[j];if(l(r,q))I=h(q,r,D);else{let l;l=e?"string"==typeof o?o:o[e]:D;const n=A?void 0:t(j,P.localePrefix),s=h(q,l,r);C=R(x(s,n,a.nextUrl.search))}}}if(!C)if("/"!==I||z){const e=x(I,v(j),a.nextUrl.search);if(z){const o=x(q,H.prefix,a.nextUrl.search);if("never"===P.localePrefix.mode)C=R(x(q,void 0,a.nextUrl.search));else if(H.exact)if(w&&A)C=R(x(q,void 0,a.nextUrl.search));else if(P.domains){const l=u(L,H.locale,k);C=(null==L?void 0:L.domain)===(null==l?void 0:l.domain)||b?y(e):R(o,null==l?void 0:l.domain)}else C=y(e);else C=R(o)}else C=A?y(e):R(x(q,t(j,P.localePrefix),a.nextUrl.search))}else C=A?y(x(I,v(j),a.nextUrl.search)):R(x(q,t(j,P.localePrefix),a.nextUrl.search));var S;(P.localeDetection&&i(a,C,j),"never"!==P.localePrefix.mode&&P.alternateLinks&&P.locales.length>1)&&C.headers.set("Link",n({config:P,localizedPathnames:null!=D?null===(S=P.pathnames)||void 0===S?void 0:S[D]:void 0,request:a,resolvedLocale:j}));return C}}export{U as default};
1
+ import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,normalizeTrailingSlash as r,getLocalePrefix as t}from"../shared/utils.js";import{receiveConfig as a}from"./config.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as x,formatPathname as u,getBestMatchingDomain as p,applyBasePath as v,getLocaleAsPrefix as U}from"./utils.js";function P(P){const g=a(P);return function(a){var P;const L=decodeURI(a.nextUrl.pathname),j=c(L),{domain:w,locale:k}=s(g,a.headers,a.cookies,j),b=w?w.defaultLocale===k:k===g.defaultLocale,y=(null===(P=g.domains)||void 0===P?void 0:P.filter((e=>d(k,e))))||[],R=null!=g.domains&&!w;function q(l){const r=new URL(l,a.url);a.nextUrl.basePath&&(r.pathname=v(r.pathname,a.nextUrl.basePath));const t=new Headers(a.headers);return t.set(o,k),e.rewrite(r,{request:{headers:t}})}function H(o,l){const t=new URL(r(o),a.url);if(y.length>0&&!l){const e=p(w,k,y);e&&(l=e.domain,e.defaultLocale===k&&"as-needed"===g.localePrefix.mode&&(t.pathname=f(t.pathname,g.locales,g.localePrefix)))}var n,s;l&&(t.host=l,a.headers.get("x-forwarded-host")&&(t.protocol=null!==(n=a.headers.get("x-forwarded-proto"))&&void 0!==n?n:a.nextUrl.protocol,t.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(t.pathname=v(t.pathname,a.nextUrl.basePath)),e.redirect(t.toString())}const z=f(j,g.locales,g.localePrefix),A=m(j,g.locales,g.localePrefix),C=null!=A,D="never"===g.localePrefix.mode||b&&"as-needed"===g.localePrefix.mode;let I,S,V=z;if(g.pathnames){let e;if([e,S]=h(g.pathnames,z,k),S){const o=g.pathnames[S],r="string"==typeof o?o:o[k];if(l(r,z))V=x(z,r,S);else{let l;l=e?"string"==typeof o?o:o[e]:S;const n=D?void 0:t(k,g.localePrefix),s=x(z,l,r);I=H(u(s,n,a.nextUrl.search))}}}if(!I)if("/"!==V||C){const e=u(V,U(k),a.nextUrl.search);if(C){const o=u(z,A.prefix,a.nextUrl.search);if("never"===g.localePrefix.mode)I=H(u(z,void 0,a.nextUrl.search));else if(A.exact)if(b&&D)I=H(u(z,void 0,a.nextUrl.search));else if(g.domains){const l=p(w,A.locale,y);I=(null==w?void 0:w.domain)===(null==l?void 0:l.domain)||R?q(e):H(o,null==l?void 0:l.domain)}else I=q(e);else I=H(o)}else I=D?q(e):H(u(z,t(k,g.localePrefix),a.nextUrl.search))}else I=D?q(u(V,U(k),a.nextUrl.search)):H(u(z,t(k,g.localePrefix),a.nextUrl.search));var B;(g.localeDetection&&i(a,I,k),"never"!==g.localePrefix.mode&&g.alternateLinks&&g.locales.length>1)&&I.headers.set("Link",n({config:g,localizedPathnames:null!=S?null===(B=g.pathnames)||void 0===B?void 0:B[S]:void 0,request:a,resolvedLocale:k}));return I}}export{P as default};
@@ -1 +1 @@
1
- import{getSortedPathnames as t,matchesPathname as e,normalizeTrailingSlash as n,getLocalePrefix as o,templateToRegex as r,prefixPathname as c}from"../shared/utils.js";function l(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 i(t,e,o,r){let c="";return c+=d(o,a(e,t)),c=n(c),c}function u(t,e,o){t.endsWith("/")||(t+="/");const r=f(e,o),c=new RegExp("^(".concat(r.map((t=>{let[,e]=t;return e.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),l=t.match(c);let i=l?"/"+l[2]:t;return"/"!==i&&(i=n(i)),i}function f(t,e){return t.map((t=>[t,o(t,e)]))}function s(t,e,n){const o=f(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 a(t,e){const o=n(e),c=n(t),l=r(c).exec(o);if(!l)return;const i={};for(let t=1;t<l.length;t++){var u;const e=null===(u=c.match(/\[([^\]]+)\]/g))||void 0===u?void 0:u[t-1].replace(/[[\]]/g,"");e&&(i[e]=l[t])}return i}function d(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 h(t,e,n){let o=t;return e&&(o=c(e,o)),n&&(o+=n),o}function p(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 v(t,e){return e.defaultLocale===t||!e.locales||e.locales.includes(t)}function g(t,e,n){let o;return t&&v(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 x(t,e){return n(e+t)}function m(t){return"/".concat(t)}export{x as applyBasePath,h as formatPathname,d as formatPathnameTemplate,i as formatTemplatePathname,g as getBestMatchingDomain,p as getHost,l as getInternalTemplate,m as getLocaleAsPrefix,f as getLocalePrefixes,u as getNormalizedPathname,s as getPathnameMatch,a as getRouteParams,v as isLocaleSupportedOnDomain};
1
+ import{getSortedPathnames as e,matchesPathname as t,normalizeTrailingSlash as n,getLocalePrefix as r,templateToRegex as o,prefixPathname as c}from"../shared/utils.js";function l(n,r,o){const c=e(Object.keys(n));for(const e of c){const c=n[e];if("string"==typeof c){if(t(c,r))return[void 0,e]}else{const n=Object.entries(c),l=n.findIndex((e=>{let[t]=e;return t===o}));l>0&&n.unshift(n.splice(l,1)[0]);for(const[o,c]of n)if(t(c,r))return[o,e]}}for(const e of Object.keys(n))if(t(e,r))return[void 0,e];return[void 0,void 0]}function i(e,t,r,o){let c="";return c+=d(r,a(t,e)),c=n(c),c}function u(e,t,r){e.endsWith("/")||(e+="/");const o=f(t,r),c=new RegExp("^(".concat(o.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),l=e.match(c);let i=l?"/"+l[2]:e;return"/"!==i&&(i=n(i)),i}function f(e,t){return e.map((e=>[e,r(e,t)]))}function s(e,t,n){const r=f(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(),c=n.toLowerCase();(t===c||t.startsWith(c+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}}function a(e,t){const r=n(t),c=n(e),l=o(c).exec(r);if(!l)return;const i={};for(let e=1;e<l.length;e++){var u;const t=null===(u=c.match(/\[([^\]]+)\]/g))||void 0===u?void 0:u[e-1].replace(/[[\]]/g,"");t&&(i[t]=l[e])}return i}function d(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 p(e,t,n){let r=e;return t&&(r=c(t,r)),n&&(r+=n),r}function h(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}function g(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function v(e,t,n){let r;return e&&g(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}function x(e,t){return n(t+e)}function m(e){return"/".concat(e)}function j(e){return e.replace(/\\/g,"%5C").replace(/\/+/g,"/")}export{x as applyBasePath,p as formatPathname,d as formatPathnameTemplate,i as formatTemplatePathname,v as getBestMatchingDomain,h as getHost,l as getInternalTemplate,m as getLocaleAsPrefix,f as getLocalePrefixes,u as getNormalizedPathname,s as getPathnameMatch,a as getRouteParams,g as isLocaleSupportedOnDomain,j as sanitizePathname};
@@ -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 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
+ import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o,useMemo as t}from"react";import n from"../../react-client/useLocale.js";import{receiveLocalizedNavigationRoutingConfig as a}from"../shared/config.js";import{getRoute as l,compileLocalizedPathname as c,normalizeNameOrNameWithParams as i}from"../shared/utils.js";import s from"./ClientLink.js";import{clientRedirect as f,clientPermanentRedirect as u}from"./redirects.js";import m from"./useBasePathname.js";import h from"./useBaseRouter.js";function p(p){const d=a(p);function v(){const e=n();if(!d.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `i18n.ts`.'));return e}function P(o,t){let{href:n,locale:a,...l}=o;const i=v(),f=a||i;return r.createElement(s,e({ref:t,href:c({locale:f,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:d.pathnames}),locale:a,localePrefix:d.localePrefix},l))}const x=o(P);function j(e){let{href:r,locale:o}=e;return c({...i(r),locale:o,pathnames:d.pathnames})}return x.displayName="Link",{Link:x,redirect:function(e){const r=j({href:e,locale:v()});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:d.localePrefix},...t)},permanentRedirect:function(e){const r=j({href:e,locale:v()});for(var o=arguments.length,t=new Array(o>1?o-1:0),n=1;n<o;n++)t[n-1]=arguments[n];return u({pathname:r,localePrefix:d.localePrefix},...t)},usePathname:function(){const e=m(d.localePrefix),r=v();return t((()=>e?l(r,e,d.pathnames):e),[r,e])},useRouter:function(){const e=h(d.localePrefix),r=v();return t((()=>({...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=j({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=j({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=j({href:o,locale:(null===(t=a[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...a)}})),[e,r])},getPathname:j}}export{p as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),{domain:f,locale:m}=o.default(c,r.headers,r.cookies,d),h=f?f.defaultLocale===m:m===c.defaultLocale,u=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(m,e))))||[],x=null!=c.domains&&!f;function P(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(l,{request:{headers:o}})}function p(a,l){const o=new URL(t.normalizeTrailingSlash(a),r.url);if(u.length>0&&!l){const e=s.getBestMatchingDomain(f,m,u);e&&(l=e.domain,e.defaultLocale===m&&"as-needed"===c.localePrefix.mode&&(o.pathname=s.getNormalizedPathname(o.pathname,c.locales,c.localePrefix)))}var n,i;l&&(o.host=l,r.headers.get("x-forwarded-host")&&(o.protocol=null!==(n=r.headers.get("x-forwarded-proto"))&&void 0!==n?n:r.nextUrl.protocol,o.port=null!==(i=r.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return r.nextUrl.basePath&&(o.pathname=s.applyBasePath(o.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(o.toString())}const g=s.getNormalizedPathname(d,c.locales,c.localePrefix),v=s.getPathnameMatch(d,c.locales,c.localePrefix),L=null!=v,U="never"===c.localePrefix.mode||h&&"as-needed"===c.localePrefix.mode;let q,j,w=g;if(c.pathnames){let e;if([e,j]=s.getInternalTemplate(c.pathnames,g,m),j){const a=c.pathnames[j],l="string"==typeof a?a:a[m];if(t.matchesPathname(l,g))w=s.formatTemplatePathname(g,l,j);else{let o;o=e?"string"==typeof a?a:a[e]:j;const n=U?void 0:t.getLocalePrefix(m,c.localePrefix),i=s.formatTemplatePathname(g,o,l);q=p(s.formatPathname(i,n,r.nextUrl.search))}}}if(!q)if("/"!==w||L){const e=s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search);if(L){const a=s.formatPathname(g,v.prefix,r.nextUrl.search);if("never"===c.localePrefix.mode)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(v.exact)if(h&&U)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(c.domains){const t=s.getBestMatchingDomain(f,v.locale,u);q=(null==f?void 0:f.domain)===(null==t?void 0:t.domain)||x?P(e):p(a,null==t?void 0:t.domain)}else q=P(e);else q=p(a)}else q=U?P(e):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search))}else q=U?P(s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search)):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search));var y;(c.localeDetection&&n.default(r,q,m),"never"!==c.localePrefix.mode&&c.alternateLinks&&c.locales.length>1)&&q.headers.set("Link",l.default({config:c,localizedPathnames:null!=j?null===(y=c.pathnames)||void 0===y?void 0:y[j]:void 0,request:r,resolvedLocale:m}));return q}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),m=s.sanitizePathname(d),{domain:f,locale:h}=o.default(c,r.headers,r.cookies,m),u=f?f.defaultLocale===h:h===c.defaultLocale,x=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(h,e))))||[],P=null!=c.domains&&!f;function p(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,h),e.NextResponse.rewrite(l,{request:{headers:o}})}function g(a,l){const o=new URL(t.normalizeTrailingSlash(a),r.url);if(x.length>0&&!l){const e=s.getBestMatchingDomain(f,h,x);e&&(l=e.domain,e.defaultLocale===h&&"as-needed"===c.localePrefix.mode&&(o.pathname=s.getNormalizedPathname(o.pathname,c.locales,c.localePrefix)))}var n,i;l&&(o.host=l,r.headers.get("x-forwarded-host")&&(o.protocol=null!==(n=r.headers.get("x-forwarded-proto"))&&void 0!==n?n:r.nextUrl.protocol,o.port=null!==(i=r.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return r.nextUrl.basePath&&(o.pathname=s.applyBasePath(o.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(o.toString())}const v=s.getNormalizedPathname(m,c.locales,c.localePrefix),L=s.getPathnameMatch(m,c.locales,c.localePrefix),U=null!=L,q="never"===c.localePrefix.mode||u&&"as-needed"===c.localePrefix.mode;let j,w,y=v;if(c.pathnames){let e;if([e,w]=s.getInternalTemplate(c.pathnames,v,h),w){const a=c.pathnames[w],l="string"==typeof a?a:a[h];if(t.matchesPathname(l,v))y=s.formatTemplatePathname(v,l,w);else{let o;o=e?"string"==typeof a?a:a[e]:w;const n=q?void 0:t.getLocalePrefix(h,c.localePrefix),i=s.formatTemplatePathname(v,o,l);j=g(s.formatPathname(i,n,r.nextUrl.search))}}}if(!j)if("/"!==y||U){const e=s.formatPathname(y,s.getLocaleAsPrefix(h),r.nextUrl.search);if(U){const a=s.formatPathname(v,L.prefix,r.nextUrl.search);if("never"===c.localePrefix.mode)j=g(s.formatPathname(v,void 0,r.nextUrl.search));else if(L.exact)if(u&&q)j=g(s.formatPathname(v,void 0,r.nextUrl.search));else if(c.domains){const t=s.getBestMatchingDomain(f,L.locale,x);j=(null==f?void 0:f.domain)===(null==t?void 0:t.domain)||P?p(e):g(a,null==t?void 0:t.domain)}else j=p(e);else j=g(a)}else j=q?p(e):g(s.formatPathname(v,t.getLocalePrefix(h,c.localePrefix),r.nextUrl.search))}else j=q?p(s.formatPathname(y,s.getLocaleAsPrefix(h),r.nextUrl.search)):g(s.formatPathname(v,t.getLocalePrefix(h,c.localePrefix),r.nextUrl.search));var A;(c.localeDetection&&n.default(r,j,h),"never"!==c.localePrefix.mode&&c.alternateLinks&&c.locales.length>1)&&j.headers.set("Link",l.default({config:c,localizedPathnames:null!=w?null===(A=c.pathnames)||void 0===A?void 0:A[w]:void 0,request:r,resolvedLocale:h}));return j}};
@@ -1 +1 @@
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 r=e.normalizeTrailingSlash(n),o=e.normalizeTrailingSlash(t),a=e.templateToRegex(o).exec(r);if(!a)return;const l={};for(let e=1;e<a.length;e++){var i;const t=null===(i=o.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[e-1].replace(/[[\]]/g,"");t&&(l[t]=a[e])}return l}function r(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 o(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}exports.applyBasePath=function(t,n){return e.normalizeTrailingSlash(n+t)},exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=r,exports.formatTemplatePathname=function(t,o,a,l){let i="";return i+=r(a,n(o,t)),i=e.normalizeTrailingSlash(i),i},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&o(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=e.getSortedPathnames(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),l=t.findIndex((e=>{let[t]=e;return t===r}));l>0&&t.unshift(t.splice(l,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=t,exports.getNormalizedPathname=function(n,r,o){n.endsWith("/")||(n+="/");const a=t(r,o),l=new RegExp("^(".concat(a.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),i=n.match(l);let s=i?"/"+i[2]:n;return"/"!==s&&(s=e.normalizeTrailingSlash(s)),s},exports.getPathnameMatch=function(e,n,r){const o=t(n,r);for(const[t,n]of o){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=n,exports.isLocaleSupportedOnDomain=o;
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 r=e.normalizeTrailingSlash(n),o=e.normalizeTrailingSlash(t),a=e.templateToRegex(o).exec(r);if(!a)return;const l={};for(let e=1;e<a.length;e++){var i;const t=null===(i=o.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[e-1].replace(/[[\]]/g,"");t&&(l[t]=a[e])}return l}function r(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 o(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}exports.applyBasePath=function(t,n){return e.normalizeTrailingSlash(n+t)},exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=r,exports.formatTemplatePathname=function(t,o,a,l){let i="";return i+=r(a,n(o,t)),i=e.normalizeTrailingSlash(i),i},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&o(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=e.getSortedPathnames(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),l=t.findIndex((e=>{let[t]=e;return t===r}));l>0&&t.unshift(t.splice(l,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=t,exports.getNormalizedPathname=function(n,r,o){n.endsWith("/")||(n+="/");const a=t(r,o),l=new RegExp("^(".concat(a.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),i=n.match(l);let s=i?"/"+i[2]:n;return"/"!==s&&(s=e.normalizeTrailingSlash(s)),s},exports.getPathnameMatch=function(e,n,r){const o=t(n,r);for(const[t,n]of o){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=n,exports.isLocaleSupportedOnDomain=o,exports.sanitizePathname=function(e){return e.replace(/\\/g,"%5C").replace(/\/+/g,"/")};
@@ -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(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
+ "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 m=r.forwardRef(d);function p(e){let{href:r,locale:a}=e;return l.compileLocalizedPathname({...l.normalizeNameOrNameWithParams(r),locale:a,pathnames:f.pathnames})}return m.displayName="Link",{Link:m,redirect:function(e){const r=p({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=p({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),a=h();return r.useMemo((()=>e?l.getRoute(a,e,f.pathnames):e),[a,e])},useRouter:function(){const e=i.default(f.localePrefix),a=h();return r.useMemo((()=>({...e,push(r){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=p({href:r,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||a});return e.push(c,...n)},replace(r){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=p({href:r,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||a});return e.replace(c,...n)},prefetch(r){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=p({href:r,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||a});return e.prefetch(c,...n)}})),[e,a])},getPathname:p}};
@@ -22,3 +22,4 @@ export declare function isLocaleSupportedOnDomain<AppLocales extends Locales>(lo
22
22
  export declare function getBestMatchingDomain<AppLocales extends Locales>(curHostDomain: DomainConfig<AppLocales> | undefined, locale: string, domainsConfig: DomainsConfig<AppLocales>): DomainConfig<AppLocales> | undefined;
23
23
  export declare function applyBasePath(pathname: string, basePath: string): string;
24
24
  export declare function getLocaleAsPrefix<AppLocales extends Locales>(locale: AppLocales[number]): string;
25
+ export declare function sanitizePathname(pathname: string): string;
@@ -26,6 +26,6 @@ type Props<AppLocales extends Locales> = Omit<ComponentProps<typeof BaseLink>, '
26
26
  * page to be overwritten before the user even decides to change the locale.
27
27
  */
28
28
  declare const ClientLinkWithRef: <AppLocales extends Locales>(props: Props<AppLocales> & {
29
- ref?: Props<AppLocales>['ref'];
29
+ ref?: Props<AppLocales>["ref"];
30
30
  }) => ReactElement;
31
31
  export default ClientLinkWithRef;
@@ -1,36 +1,35 @@
1
- /// <reference types="node" />
2
1
  import React, { ComponentProps, ReactElement } from 'react';
3
2
  import { Locales, Pathnames } from '../../routing/types';
4
3
  import { LocalizedNavigationRoutingConfigInput } from '../shared/config';
5
4
  import { HrefOrHrefWithParams } from '../shared/utils';
6
5
  import ClientLink from './ClientLink';
7
6
  export default function createLocalizedPathnamesNavigation<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(input: LocalizedNavigationRoutingConfigInput<AppLocales, AppPathnames>): {
8
- Link: <Pathname extends keyof AppPathnames>(props: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
7
+ Link: <Pathname extends keyof AppPathnames>(props: (Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
9
8
  href: string | import("url").UrlObject;
10
- as?: (string | import("url").UrlObject) | undefined;
11
- replace?: boolean | undefined;
12
- scroll?: boolean | undefined;
13
- shallow?: boolean | undefined;
14
- passHref?: boolean | undefined;
15
- prefetch?: boolean | undefined;
16
- locale?: string | false | undefined;
17
- legacyBehavior?: boolean | undefined;
18
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
19
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
20
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
9
+ as?: string | import("url").UrlObject;
10
+ replace?: boolean;
11
+ scroll?: boolean;
12
+ shallow?: boolean;
13
+ passHref?: boolean;
14
+ prefetch?: boolean;
15
+ locale?: string | false;
16
+ legacyBehavior?: boolean;
17
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
18
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
19
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
21
20
  }> & {
22
21
  href: string | import("url").UrlObject;
23
- as?: (string | import("url").UrlObject) | undefined;
24
- replace?: boolean | undefined;
25
- scroll?: boolean | undefined;
26
- shallow?: boolean | undefined;
27
- passHref?: boolean | undefined;
28
- prefetch?: boolean | undefined;
29
- locale?: string | false | undefined;
30
- legacyBehavior?: boolean | undefined;
31
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
32
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
33
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
22
+ as?: string | import("url").UrlObject;
23
+ replace?: boolean;
24
+ scroll?: boolean;
25
+ shallow?: boolean;
26
+ passHref?: boolean;
27
+ prefetch?: boolean;
28
+ locale?: string | false;
29
+ legacyBehavior?: boolean;
30
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
31
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
32
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
34
33
  } & {
35
34
  children?: React.ReactNode;
36
35
  } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
@@ -52,21 +51,21 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
52
51
  } & Omit<import("url").UrlObject, "pathname"> : Pathname | ({
53
52
  pathname: Pathname;
54
53
  } & Omit<import("url").UrlObject, "pathname">);
55
- locale?: AppLocales[number] | undefined;
56
- } & {
57
- ref?: ComponentProps<typeof ClientLink>['ref'];
54
+ locale?: AppLocales[number];
55
+ }) & {
56
+ ref?: ComponentProps<typeof ClientLink>["ref"];
58
57
  }) => ReactElement;
59
- redirect: <Pathname_1 extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname_1>, type?: import("next/navigation").RedirectType | undefined) => never;
60
- permanentRedirect: <Pathname_2 extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname_2>, type?: import("next/navigation").RedirectType | undefined) => never;
58
+ redirect: <Pathname extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname>, type?: import("next/navigation").RedirectType | undefined) => never;
59
+ permanentRedirect: <Pathname extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname>, type?: import("next/navigation").RedirectType | undefined) => never;
61
60
  usePathname: () => keyof AppPathnames;
62
61
  useRouter: () => {
63
- push<Pathname_3 extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname_3>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & {
62
+ push<Pathname extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & {
64
63
  locale?: AppLocales[number] | undefined;
65
64
  }) | undefined): void;
66
- replace<Pathname_4 extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname_4>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & {
65
+ replace<Pathname extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & {
67
66
  locale?: AppLocales[number] | undefined;
68
67
  }) | undefined): void;
69
- prefetch<Pathname_5 extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname_5>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").PrefetchOptions & {
68
+ prefetch<Pathname extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").PrefetchOptions & {
70
69
  locale?: AppLocales[number] | undefined;
71
70
  }) | undefined): void;
72
71
  back(): void;
@@ -1,34 +1,33 @@
1
- /// <reference types="node" />
2
1
  import React, { ReactElement } from 'react';
3
2
  import { Locales } from '../../routing/types';
4
3
  import { SharedNavigationRoutingConfigInput } from '../shared/config';
5
4
  export default function createSharedPathnamesNavigation<const AppLocales extends Locales>(input?: SharedNavigationRoutingConfigInput<AppLocales>): {
6
5
  Link: (props: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
7
6
  href: string | import("url").UrlObject;
8
- as?: (string | import("url").UrlObject) | undefined;
9
- replace?: boolean | undefined;
10
- scroll?: boolean | undefined;
11
- shallow?: boolean | undefined;
12
- passHref?: boolean | undefined;
13
- prefetch?: boolean | undefined;
14
- locale?: string | false | undefined;
15
- legacyBehavior?: boolean | undefined;
16
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
17
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
18
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
7
+ as?: string | import("url").UrlObject;
8
+ replace?: boolean;
9
+ scroll?: boolean;
10
+ shallow?: boolean;
11
+ passHref?: boolean;
12
+ prefetch?: boolean;
13
+ locale?: string | false;
14
+ legacyBehavior?: boolean;
15
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
16
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
17
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
19
18
  }> & {
20
19
  href: string | import("url").UrlObject;
21
- as?: (string | import("url").UrlObject) | undefined;
22
- replace?: boolean | undefined;
23
- scroll?: boolean | undefined;
24
- shallow?: boolean | undefined;
25
- passHref?: boolean | undefined;
26
- prefetch?: boolean | undefined;
27
- locale?: string | false | undefined;
28
- legacyBehavior?: boolean | undefined;
29
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
30
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
31
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
20
+ as?: string | import("url").UrlObject;
21
+ replace?: boolean;
22
+ scroll?: boolean;
23
+ shallow?: boolean;
24
+ passHref?: boolean;
25
+ prefetch?: boolean;
26
+ locale?: string | false;
27
+ legacyBehavior?: boolean;
28
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
29
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
30
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
32
31
  } & {
33
32
  children?: React.ReactNode;
34
33
  } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
@@ -1,10 +1,10 @@
1
- export declare const clientRedirect: (params: Omit<{
1
+ export declare const clientRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
2
2
  pathname: string;
3
- locale: string;
4
- localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<import("../../routing/types").Locales>;
5
- }, "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
6
- export declare const clientPermanentRedirect: (params: Omit<{
3
+ locale: import("../../routing/types").Locales[number];
4
+ localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
5
+ }, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
6
+ export declare const clientPermanentRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
7
7
  pathname: string;
8
- locale: string;
9
- localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<import("../../routing/types").Locales>;
10
- }, "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
8
+ locale: import("../../routing/types").Locales[number];
9
+ localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
10
+ }, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import React from 'react';
3
2
  import { Locales, Pathnames } from '../../routing/types';
4
3
  import { LocalizedNavigationRoutingConfigInput } from '../shared/config';
@@ -6,30 +5,30 @@ import { HrefOrHrefWithParams } from '../shared/utils';
6
5
  export default function createLocalizedPathnamesNavigation<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(input: LocalizedNavigationRoutingConfigInput<AppLocales, AppPathnames>): {
7
6
  Link: <Pathname extends keyof AppPathnames>({ href, locale, ...rest }: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
8
7
  href: string | import("url").UrlObject;
9
- as?: (string | import("url").UrlObject) | undefined;
10
- replace?: boolean | undefined;
11
- scroll?: boolean | undefined;
12
- shallow?: boolean | undefined;
13
- passHref?: boolean | undefined;
14
- prefetch?: boolean | undefined;
15
- locale?: string | false | undefined;
16
- legacyBehavior?: boolean | undefined;
17
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
18
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
19
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
8
+ as?: string | import("url").UrlObject;
9
+ replace?: boolean;
10
+ scroll?: boolean;
11
+ shallow?: boolean;
12
+ passHref?: boolean;
13
+ prefetch?: boolean;
14
+ locale?: string | false;
15
+ legacyBehavior?: boolean;
16
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
17
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
18
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
20
19
  }> & {
21
20
  href: string | import("url").UrlObject;
22
- as?: (string | import("url").UrlObject) | undefined;
23
- replace?: boolean | undefined;
24
- scroll?: boolean | undefined;
25
- shallow?: boolean | undefined;
26
- passHref?: boolean | undefined;
27
- prefetch?: boolean | undefined;
28
- locale?: string | false | undefined;
29
- legacyBehavior?: boolean | undefined;
30
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
31
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
32
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
21
+ as?: string | import("url").UrlObject;
22
+ replace?: boolean;
23
+ scroll?: boolean;
24
+ shallow?: boolean;
25
+ passHref?: boolean;
26
+ prefetch?: boolean;
27
+ locale?: string | false;
28
+ legacyBehavior?: boolean;
29
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
30
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
31
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
33
32
  } & {
34
33
  children?: React.ReactNode;
35
34
  } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
@@ -49,10 +48,10 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
49
48
  } & Omit<import("url").UrlObject, "pathname"> : Pathname | ({
50
49
  pathname: Pathname;
51
50
  } & Omit<import("url").UrlObject, "pathname">);
52
- locale?: AppLocales[number] | undefined;
51
+ locale?: AppLocales[number];
53
52
  }) => React.JSX.Element;
54
- redirect: <Pathname_1 extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname_1>, type?: import("next/navigation").RedirectType | undefined) => never;
55
- permanentRedirect: <Pathname_2 extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname_2>, type?: import("next/navigation").RedirectType | undefined) => never;
53
+ redirect: <Pathname extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname>, type?: import("next/navigation").RedirectType | undefined) => never;
54
+ permanentRedirect: <Pathname extends keyof AppPathnames>(href: HrefOrHrefWithParams<Pathname>, type?: import("next/navigation").RedirectType | undefined) => never;
56
55
  getPathname: ({ href, locale }: {
57
56
  locale: AppLocales[number];
58
57
  href: HrefOrHrefWithParams<keyof AppPathnames>;
@@ -3,7 +3,7 @@ import { Locales } from '../../routing/types';
3
3
  import { SharedNavigationRoutingConfigInput } from '../shared/config';
4
4
  import ServerLink from './ServerLink';
5
5
  export default function createSharedPathnamesNavigation<AppLocales extends Locales>(input?: SharedNavigationRoutingConfigInput<AppLocales>): {
6
- Link: (props: Omit<ComponentProps<typeof ServerLink<AppLocales>>, 'localePrefix' | 'locales'>) => React.JSX.Element;
6
+ Link: (props: Omit<ComponentProps<typeof ServerLink<AppLocales>>, "localePrefix" | "locales">) => React.JSX.Element;
7
7
  redirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
8
8
  permanentRedirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
9
9
  usePathname: () => never;
@@ -1,10 +1,10 @@
1
- export declare const serverRedirect: (params: Omit<{
1
+ export declare const serverRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
2
2
  pathname: string;
3
- locale: string;
4
- localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<import("../../routing/types").Locales>;
5
- }, "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
6
- export declare const serverPermanentRedirect: (params: Omit<{
3
+ locale: import("../../routing/types").Locales[number];
4
+ localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
5
+ }, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
6
+ export declare const serverPermanentRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
7
7
  pathname: string;
8
- locale: string;
9
- localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<import("../../routing/types").Locales>;
10
- }, "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
8
+ locale: import("../../routing/types").Locales[number];
9
+ localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
10
+ }, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { ParsedUrlQueryInput } from 'node:querystring';
4
2
  import type { UrlObject } from 'url';
5
3
  import { Locales, Pathnames } from '../../routing/types';
@@ -1,9 +1,9 @@
1
- import type { getRequestConfig as getRequestConfig_type, getFormatter as getFormatter_type, getNow as getNow_type, getTimeZone as getTimeZone_type, getMessages as getMessages_type, unstable_setRequestLocale as unstable_setRequestLocale_type } from '../react-server';
1
+ import type { getRequestConfig as getRequestConfig_type, getFormatter as getFormatter_type, getNow as getNow_type, getTimeZone as getTimeZone_type, getMessages as getMessages_type, getLocale as getLocale_type, unstable_setRequestLocale as unstable_setRequestLocale_type } from '../react-server';
2
2
  export declare function getRequestConfig(...args: Parameters<typeof getRequestConfig_type>): ReturnType<typeof getRequestConfig_type>;
3
3
  export declare const getFormatter: typeof getFormatter_type;
4
4
  export declare const getNow: typeof getNow_type;
5
5
  export declare const getTimeZone: typeof getTimeZone_type;
6
6
  export declare const getMessages: typeof getMessages_type;
7
- export declare const getLocale: () => Promise<string>;
7
+ export declare const getLocale: typeof getLocale_type;
8
8
  export declare const getTranslations: () => never;
9
9
  export declare const unstable_setRequestLocale: typeof unstable_setRequestLocale_type;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { UrlObject } from 'url';
3
2
  import NextLink from 'next/link';
4
3
  import { ComponentProps } from 'react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.17.0",
3
+ "version": "3.17.2",
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.0"
90
+ "use-intl": "^3.17.2"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
@@ -104,7 +104,7 @@
104
104
  },
105
105
  {
106
106
  "path": "dist/production/navigation.react-client.js",
107
- "limit": "3.465 KB"
107
+ "limit": "3.475 KB"
108
108
  },
109
109
  {
110
110
  "path": "dist/production/navigation.react-server.js",
@@ -120,12 +120,12 @@
120
120
  },
121
121
  {
122
122
  "path": "dist/production/middleware.js",
123
- "limit": "6.485 KB"
123
+ "limit": "6.525 KB"
124
124
  },
125
125
  {
126
126
  "path": "dist/production/routing.js",
127
127
  "limit": "0 KB"
128
128
  }
129
129
  ],
130
- "gitHead": "bef3544202e88849646583e63b4751b82d1690a0"
130
+ "gitHead": "b2117e10bab62c4b26cbd712551816a22a71e63f"
131
131
  }