-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
perf(next-international): optimize middleware #292
Conversation
Someone is attempting to deploy a commit to a Personal Account owned by @QuiiBz on Vercel. @QuiiBz first needs to authorize it. |
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.
Thanks for the comments and improvements! Left a suggestion:
if (noLocalePrefix(config.locales, requestUrl.pathname)) { | ||
requestUrl.pathname = `/${locale}${requestUrl.pathname}`; | ||
// If the locale from the request is not an handled locale, then redirect to the same URL with the default locale | ||
if (!hasHandledLocale(config.locales, nextUrl.pathname)) { |
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.
Not a fan of the updated function name + the negation. Could we revert the changes?
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.
Just tested and everything seems to work as expected, thanks!
String.prototype.split
param #238, when the URL are becoming long like https://github.com/QuiiBz/next-international/issues/..., there will be no loss of performance.redirect
part but I'm not sure it's easy to read and understand this part so don't hesitate to give your opinion.localeFromRequest
function, there were several assignments that weren't necessary, so I merged them.clone()
call (fromnextUrl
) because it creates a new instance and it seems to be no longer documented on the doc, only on error messages