-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: middleware i18n normalization #2483
Conversation
📊 Package size report -0.01%↓
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
edge-runtime/lib/next-request.ts
Outdated
url.pathname = pathname || '/' | ||
} | ||
detectedLocale = detected | ||
;({ detectedLocale } = normalizeLocalePath(pathname, nextConfig?.i18n?.locales)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This reads a bit weird. Could we do a regular assignment to detectLocale
, or is the linter complaining about not using destructuring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I realised that normalizeLocalePath
will return undefined
for detectedLocale
if nextConfig.i18n
is undefined, so the conditional wasn't necessary, meaning I can use regular destructuring to a const
. Fixed in 13a8cce
5abd081
to
13a8cce
Compare
Description
Fixes a regression from a previous PR that manifests itself when using the
skipMiddlewareUrlNormalize
option innext.config.js
. In this scenario, the locale was being duplicated during middleware rewrites.The cause was incorrect URL normalization logic in the middleware request handling.
Tests
Integration tests added
Relevant links (GitHub issues, etc.) or a picture of cute animal
Fixes FRA-565