fix: return correct locale in root 404 and 500 page with i18n#12365
fix: return correct locale in root 404 and 500 page with i18n#12365ematipico merged 14 commits intowithastro:mainfrom
Conversation
|
| computedLocale = computeCurrentLocale(url.pathname, locales, defaultLocale); | ||
| } | ||
| const pathname = | ||
| routeData.pathname && routeData.pathname !== '/404' ? routeData.pathname : url.pathname; |
There was a problem hiding this comment.
The 404 check isn't strong enough, because it fail for /404/, for example. You should actually use routeData.pattern.test('/404'). Also, while we are at it, we should include 500 too, since users can have a 500.astro
I think you should create a function in routing/match.ts, calling is isRoute404or500(), which accept a RouteData
There was a problem hiding this comment.
Thanks. I will make those changes.
There was a problem hiding this comment.
Added requested changes. PR is ready for re-review.
CodSpeed Performance ReportMerging #12365 will not alter performanceComparing Summary
|
|
The test failing seems to be a fluke, and it's not related to your changes. Thank you for the fix! |
Changes
This PR fixes the issue where
Astro.currentLocalewas not correctly returning the locale for custom 404 and 500 pages in projects using i18n.Closes #12356
Testing
Manually verified in dev server and SSR.
Added Dev and SSR tests custom for vertifying locale in custom 404 pages.
Docs
It is not needed as it is a bug fix