next-intl 4.3.9 → 4.3.11

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.
@@ -30,18 +30,27 @@ function createMiddleware(routing) {
30
30
  const hasMatchedDefaultLocale = domain ? domain.defaultLocale === locale : locale === resolvedRouting.defaultLocale;
31
31
  const domainsConfig = resolvedRouting.domains?.filter(curDomain => isLocaleSupportedOnDomain(locale, curDomain)) || [];
32
32
  const hasUnknownHost = resolvedRouting.domains != null && !domain;
33
- function rewrite(url) {
33
+ function next(url) {
34
34
  const urlObj = new URL(url, request.url);
35
35
  if (request.nextUrl.basePath) {
36
36
  urlObj.pathname = applyBasePath(urlObj.pathname, request.nextUrl.basePath);
37
37
  }
38
38
  const headers = new Headers(request.headers);
39
39
  headers.set(HEADER_LOCALE_NAME, locale);
40
- return NextResponse.rewrite(urlObj, {
41
- request: {
42
- headers
43
- }
44
- });
40
+ const isRewriteNecessary = normalizeTrailingSlash(request.nextUrl.pathname) !== normalizeTrailingSlash(urlObj.pathname);
41
+ if (isRewriteNecessary) {
42
+ return NextResponse.rewrite(urlObj, {
43
+ request: {
44
+ headers
45
+ }
46
+ });
47
+ } else {
48
+ return NextResponse.next({
49
+ request: {
50
+ headers
51
+ }
52
+ });
53
+ }
45
54
  }
46
55
  function redirect(url, redirectDomain) {
47
56
  const urlObj = new URL(url, request.url);
@@ -105,7 +114,7 @@ function createMiddleware(routing) {
105
114
  if (!response) {
106
115
  if (unprefixedInternalPathname === '/' && !hasLocalePrefix) {
107
116
  if (isUnprefixedRouting) {
108
- response = rewrite(formatPathname(unprefixedInternalPathname, getLocaleAsPrefix(locale), request.nextUrl.search));
117
+ response = next(formatPathname(unprefixedInternalPathname, getLocaleAsPrefix(locale), request.nextUrl.search));
109
118
  } else {
110
119
  response = redirect(formatPathname(unprefixedExternalPathname, getLocalePrefix(locale, resolvedRouting.localePrefix), request.nextUrl.search));
111
120
  }
@@ -124,10 +133,10 @@ function createMiddleware(routing) {
124
133
  if (domain?.domain !== pathDomain?.domain && !hasUnknownHost) {
125
134
  response = redirect(externalHref, pathDomain?.domain);
126
135
  } else {
127
- response = rewrite(internalHref);
136
+ response = next(internalHref);
128
137
  }
129
138
  } else {
130
- response = rewrite(internalHref);
139
+ response = next(internalHref);
131
140
  }
132
141
  }
133
142
  } else {
@@ -135,7 +144,7 @@ function createMiddleware(routing) {
135
144
  }
136
145
  } else {
137
146
  if (isUnprefixedRouting) {
138
- response = rewrite(internalHref);
147
+ response = next(internalHref);
139
148
  } else {
140
149
  response = redirect(formatPathname(unprefixedExternalPathname, getLocalePrefix(locale, resolvedRouting.localePrefix), request.nextUrl.search));
141
150
  }
@@ -1 +1 @@
1
- import{NextResponse as e}from"next/server";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as o,normalizeTrailingSlash as a,getLocalePrefix as l,getLocalizedTemplate as n}from"../shared/utils.js";import s from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import c from"./syncCookie.js";import{sanitizePathname as d,isLocaleSupportedOnDomain as f,getNormalizedPathname as m,getPathnameMatch as h,getInternalTemplate as x,formatTemplatePathname as p,formatPathname as u,getBestMatchingDomain as U,applyBasePath as P,getLocaleAsPrefix as g}from"./utils.js";function v(v){const L=t(v);return function(t){let v;try{v=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const j=d(v),{domain:w,locale:k}=i(L,t.headers,t.cookies,j),b=w?w.defaultLocale===k:k===L.defaultLocale,R=L.domains?.filter((e=>f(k,e)))||[],q=null!=L.domains&&!w;function y(o){const a=new URL(o,t.url);t.nextUrl.basePath&&(a.pathname=P(a.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);return l.set(r,k),e.rewrite(a,{request:{headers:l}})}function H(r,o){const l=new URL(r,t.url);if(l.pathname=a(l.pathname),R.length>0&&!o&&w){const e=U(w,k,R);e&&(o=e.domain,e.defaultLocale===k&&"as-needed"===L.localePrefix.mode&&(l.pathname=m(l.pathname,L.locales,L.localePrefix)))}if(o&&(l.host=o,t.headers.get("x-forwarded-host"))){l.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol;const e=o.split(":")[1];l.port=e??t.headers.get("x-forwarded-port")??""}return t.nextUrl.basePath&&(l.pathname=P(l.pathname,t.nextUrl.basePath)),T=!0,e.redirect(l.toString())}const z=m(j,L.locales,L.localePrefix),A=h(j,L.locales,L.localePrefix,w),C=null!=A,I="never"===L.localePrefix.mode||b&&"as-needed"===L.localePrefix.mode;let N,S,T,V=z;const B=L.pathnames;if(B){let e;if([e,S]=x(B,z,k),S){const r=B[S],a=n(r,k,S);if(o(a,z))V=p(z,a,S);else{let o;o=e?n(r,e,S):S;const s=I?void 0:l(k,L.localePrefix),i=p(z,o,a);N=H(u(i,s,t.nextUrl.search))}}}if(!N)if("/"!==V||C){const e=u(V,g(k),t.nextUrl.search);if(C){const r=u(z,A.prefix,t.nextUrl.search);if("never"===L.localePrefix.mode)N=H(u(z,void 0,t.nextUrl.search));else if(A.exact)if(b&&I)N=H(u(z,void 0,t.nextUrl.search));else if(L.domains){const t=U(w,A.locale,R);N=w?.domain===t?.domain||q?y(e):H(r,t?.domain)}else N=y(e);else N=H(r)}else N=I?y(e):H(u(z,l(k,L.localePrefix),t.nextUrl.search))}else N=I?y(u(V,g(k),t.nextUrl.search)):H(u(z,l(k,L.localePrefix),t.nextUrl.search));return c(t,N,k,L,w),!T&&"never"!==L.localePrefix.mode&&L.alternateLinks&&L.locales.length>1&&N.headers.set("Link",s({routing:L,internalTemplateName:S,localizedPathnames:null!=S&&B?B[S]:void 0,request:t,resolvedLocale:k})),N}}export{v as default};
1
+ import{NextResponse as e}from"next/server";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as a,normalizeTrailingSlash as o,getLocalePrefix as l,getLocalizedTemplate as n}from"../shared/utils.js";import s from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import c from"./syncCookie.js";import{sanitizePathname as d,isLocaleSupportedOnDomain as f,getNormalizedPathname as m,getPathnameMatch as h,getInternalTemplate as x,formatTemplatePathname as p,formatPathname as u,getBestMatchingDomain as U,applyBasePath as P,getLocaleAsPrefix as g}from"./utils.js";function v(v){const L=t(v);return function(t){let v;try{v=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const j=d(v),{domain:w,locale:k}=i(L,t.headers,t.cookies,j),b=w?w.defaultLocale===k:k===L.defaultLocale,q=L.domains?.filter((e=>f(k,e)))||[],R=null!=L.domains&&!w;function y(a){const l=new URL(a,t.url);t.nextUrl.basePath&&(l.pathname=P(l.pathname,t.nextUrl.basePath));const n=new Headers(t.headers);n.set(r,k);return o(t.nextUrl.pathname)!==o(l.pathname)?e.rewrite(l,{request:{headers:n}}):e.next({request:{headers:n}})}function H(r,a){const l=new URL(r,t.url);if(l.pathname=o(l.pathname),q.length>0&&!a&&w){const e=U(w,k,q);e&&(a=e.domain,e.defaultLocale===k&&"as-needed"===L.localePrefix.mode&&(l.pathname=m(l.pathname,L.locales,L.localePrefix)))}if(a&&(l.host=a,t.headers.get("x-forwarded-host"))){l.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol;const e=a.split(":")[1];l.port=e??t.headers.get("x-forwarded-port")??""}return t.nextUrl.basePath&&(l.pathname=P(l.pathname,t.nextUrl.basePath)),T=!0,e.redirect(l.toString())}const z=m(j,L.locales,L.localePrefix),A=h(j,L.locales,L.localePrefix,w),C=null!=A,I="never"===L.localePrefix.mode||b&&"as-needed"===L.localePrefix.mode;let N,S,T,V=z;const B=L.pathnames;if(B){let e;if([e,S]=x(B,z,k),S){const r=B[S],o=n(r,k,S);if(a(o,z))V=p(z,o,S);else{let a;a=e?n(r,e,S):S;const s=I?void 0:l(k,L.localePrefix),i=p(z,a,o);N=H(u(i,s,t.nextUrl.search))}}}if(!N)if("/"!==V||C){const e=u(V,g(k),t.nextUrl.search);if(C){const r=u(z,A.prefix,t.nextUrl.search);if("never"===L.localePrefix.mode)N=H(u(z,void 0,t.nextUrl.search));else if(A.exact)if(b&&I)N=H(u(z,void 0,t.nextUrl.search));else if(L.domains){const t=U(w,A.locale,q);N=w?.domain===t?.domain||R?y(e):H(r,t?.domain)}else N=y(e);else N=H(r)}else N=I?y(e):H(u(z,l(k,L.localePrefix),t.nextUrl.search))}else N=I?y(u(V,g(k),t.nextUrl.search)):H(u(z,l(k,L.localePrefix),t.nextUrl.search));return c(t,N,k,L,w),!T&&"never"!==L.localePrefix.mode&&L.alternateLinks&&L.locales.length>1&&N.headers.set("Link",s({routing:L,internalTemplateName:S,localizedPathnames:null!=S&&B?B[S]:void 0,request:t,resolvedLocale:k})),N}}export{v as default};
@@ -75,12 +75,14 @@ export default function createNavigation<const AppLocales extends Locales, const
75
75
  results?: number | undefined | undefined;
76
76
  security?: string | undefined | undefined;
77
77
  unselectable?: "on" | "off" | undefined | undefined;
78
- popover?: "" | "auto" | "manual" | undefined | undefined;
78
+ popover?: "" | "auto" | "manual" | "hint" | undefined | undefined;
79
79
  popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
80
80
  popoverTarget?: string | undefined | undefined;
81
81
  inert?: boolean | undefined | undefined;
82
82
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
83
83
  is?: string | undefined | undefined;
84
+ exportparts?: string | undefined | undefined;
85
+ part?: string | undefined | undefined;
84
86
  tw?: string | undefined;
85
87
  "aria-activedescendant"?: string | undefined | undefined;
86
88
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
@@ -156,7 +158,7 @@ export default function createNavigation<const AppLocales extends Locales, const
156
158
  onBlurCapture?: import("react").FocusEventHandler<HTMLAnchorElement> | undefined;
157
159
  onChange?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
158
160
  onChangeCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
159
- onBeforeInput?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
161
+ onBeforeInput?: import("react").InputEventHandler<HTMLAnchorElement> | undefined;
160
162
  onBeforeInputCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
161
163
  onInput?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
162
164
  onInputCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
@@ -205,8 +207,6 @@ export default function createNavigation<const AppLocales extends Locales, const
205
207
  onProgressCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
206
208
  onRateChange?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
207
209
  onRateChangeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
208
- onResize?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
209
- onResizeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
210
210
  onSeeked?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
211
211
  onSeekedCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
212
212
  onSeeking?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
@@ -284,6 +284,8 @@ export default function createNavigation<const AppLocales extends Locales, const
284
284
  onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
285
285
  onScroll?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
286
286
  onScrollCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
287
+ onScrollEnd?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
288
+ onScrollEndCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
287
289
  onWheel?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
288
290
  onWheelCapture?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
289
291
  onAnimationStart?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
@@ -76,12 +76,14 @@ export default function createNavigation<const AppLocales extends Locales, const
76
76
  results?: number | undefined | undefined;
77
77
  security?: string | undefined | undefined;
78
78
  unselectable?: "on" | "off" | undefined | undefined;
79
- popover?: "" | "auto" | "manual" | undefined | undefined;
79
+ popover?: "" | "auto" | "manual" | "hint" | undefined | undefined;
80
80
  popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
81
81
  popoverTarget?: string | undefined | undefined;
82
82
  inert?: boolean | undefined | undefined;
83
83
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
84
84
  is?: string | undefined | undefined;
85
+ exportparts?: string | undefined | undefined;
86
+ part?: string | undefined | undefined;
85
87
  tw?: string | undefined;
86
88
  "aria-activedescendant"?: string | undefined | undefined;
87
89
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
@@ -157,7 +159,7 @@ export default function createNavigation<const AppLocales extends Locales, const
157
159
  onBlurCapture?: import("react").FocusEventHandler<HTMLAnchorElement> | undefined;
158
160
  onChange?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
159
161
  onChangeCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
160
- onBeforeInput?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
162
+ onBeforeInput?: import("react").InputEventHandler<HTMLAnchorElement> | undefined;
161
163
  onBeforeInputCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
162
164
  onInput?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
163
165
  onInputCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
@@ -206,8 +208,6 @@ export default function createNavigation<const AppLocales extends Locales, const
206
208
  onProgressCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
207
209
  onRateChange?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
208
210
  onRateChangeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
209
- onResize?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
210
- onResizeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
211
211
  onSeeked?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
212
212
  onSeekedCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
213
213
  onSeeking?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
@@ -285,6 +285,8 @@ export default function createNavigation<const AppLocales extends Locales, const
285
285
  onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
286
286
  onScroll?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
287
287
  onScrollCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
288
+ onScrollEnd?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
289
+ onScrollEndCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
288
290
  onWheel?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
289
291
  onWheelCapture?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
290
292
  onAnimationStart?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
@@ -94,12 +94,14 @@ export default function createSharedNavigationFns<const AppLocales extends Local
94
94
  results?: number | undefined | undefined;
95
95
  security?: string | undefined | undefined;
96
96
  unselectable?: "on" | "off" | undefined | undefined;
97
- popover?: "" | "auto" | "manual" | undefined | undefined;
97
+ popover?: "" | "auto" | "manual" | "hint" | undefined | undefined;
98
98
  popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
99
99
  popoverTarget?: string | undefined | undefined;
100
100
  inert?: boolean | undefined | undefined;
101
101
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
102
102
  is?: string | undefined | undefined;
103
+ exportparts?: string | undefined | undefined;
104
+ part?: string | undefined | undefined;
103
105
  tw?: string | undefined;
104
106
  "aria-activedescendant"?: string | undefined | undefined;
105
107
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
@@ -175,7 +177,7 @@ export default function createSharedNavigationFns<const AppLocales extends Local
175
177
  onBlurCapture?: import("react").FocusEventHandler<HTMLAnchorElement> | undefined;
176
178
  onChange?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
177
179
  onChangeCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
178
- onBeforeInput?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
180
+ onBeforeInput?: import("react").InputEventHandler<HTMLAnchorElement> | undefined;
179
181
  onBeforeInputCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
180
182
  onInput?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
181
183
  onInputCapture?: import("react").FormEventHandler<HTMLAnchorElement> | undefined;
@@ -224,8 +226,6 @@ export default function createSharedNavigationFns<const AppLocales extends Local
224
226
  onProgressCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
225
227
  onRateChange?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
226
228
  onRateChangeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
227
- onResize?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
228
- onResizeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
229
229
  onSeeked?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
230
230
  onSeekedCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
231
231
  onSeeking?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
@@ -303,6 +303,8 @@ export default function createSharedNavigationFns<const AppLocales extends Local
303
303
  onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
304
304
  onScroll?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
305
305
  onScrollCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
306
+ onScrollEnd?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
307
+ onScrollEndCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
306
308
  onWheel?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
307
309
  onWheelCapture?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
308
310
  onAnimationStart?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "funding": [
@@ -112,7 +112,7 @@
112
112
  "dependencies": {
113
113
  "@formatjs/intl-localematcher": "^0.5.4",
114
114
  "negotiator": "^1.0.0",
115
- "use-intl": "^4.3.9"
115
+ "use-intl": "^4.3.11"
116
116
  },
117
117
  "peerDependencies": {
118
118
  "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
@@ -124,5 +124,5 @@
124
124
  "optional": true
125
125
  }
126
126
  },
127
- "gitHead": "b927ead9d8c48da4ec01c1c6a32fc30c5c19353b"
127
+ "gitHead": "14b2c6a067b19ed33e9604147b449d4ddec3514f"
128
128
  }