Skip to content

Commit

Permalink
fix(core): encode localeConfig key
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed May 17, 2024
1 parent 8b1f0fd commit 0ac0820
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/shared/src/utils/resolveLocalePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export const resolveLocalePath = (
locales: LocaleConfig,
routePath: string,
): string => {
const localePaths = Object.keys(locales).sort((a, b) => {
const levelDelta = b.split('/').length - a.split('/').length
if (levelDelta !== 0) {
return levelDelta
}
return b.length - a.length
})
const localePaths = Object.keys(locales)
.map(encodeURI)
.sort((a, b) => {
const levelDelta = b.split('/').length - a.split('/').length
if (levelDelta !== 0) {
return levelDelta
}
return b.length - a.length
})

for (const localePath of localePaths) {
if (routePath.startsWith(localePath)) {
Expand Down

0 comments on commit 0ac0820

Please sign in to comment.