Skip to content

Commit b010192

Browse files
committed
feat: allow for locale fallbacks when adding locale prefix
1 parent 1160801 commit b010192

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

edge-runtime/lib/util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ export const addBasePath = (path: string, basePath?: string) => {
2929
return path
3030
}
3131

32+
// add locale prefix if not present, allowing for locale fallbacks
3233
export const addLocale = (path: string, locale?: string) => {
3334
if (
3435
locale &&
3536
path.toLowerCase() !== `/${locale.toLowerCase()}` &&
36-
!path.toLowerCase().startsWith(`/${locale.toLowerCase()}/`)
37+
!path.toLowerCase().startsWith(`/${locale.toLowerCase()}/`) &&
38+
!path.toLowerCase().startsWith(`/${locale.toLowerCase()}-`)
3739
) {
3840
return `/${locale}${path}`
3941
}

0 commit comments

Comments
 (0)