summaryrefslogtreecommitdiff
path: root/src/lib/getLocaleFromPath.ts
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+joeacarstairs@users.noreply.github.com>2025-01-08 19:06:59 +0000
committerGitHub <noreply@github.com>2025-01-08 19:06:59 +0000
commit7c9e28c1f614cbab7f84344be840e9aec0bc194c (patch)
tree205afc5e3b411bd2ee84b83287307b2deb4d4192 /src/lib/getLocaleFromPath.ts
parent9fb9e47e92049b72cdc7cbaa3e9d43ed1aacd095 (diff)
parent7e0219994b0f62b7d17310f5adebb549e129c952 (diff)
Merge pull request #110 from joeacarstairs/staging
Update
Diffstat (limited to 'src/lib/getLocaleFromPath.ts')
-rw-r--r--src/lib/getLocaleFromPath.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/getLocaleFromPath.ts b/src/lib/getLocaleFromPath.ts
index 2cfaf41..b1e815c 100644
--- a/src/lib/getLocaleFromPath.ts
+++ b/src/lib/getLocaleFromPath.ts
@@ -1,13 +1,14 @@
import locales, { defaultLocale } from '$i18n/locales';
import type Locale from '$types/Locale';
+import { correctLocaleCasing } from './correctLocaleCasing';
export function getLocaleFromPath(path: string): Locale | null {
- const regex = new RegExp(`^/(${locales.join('|')})`);
+ const regex = new RegExp(`^/(${locales.join('|')})`, 'i');
const match = path.match(regex)?.[1];
if (!match) {
return null;
}
- return match as Locale;
+ return correctLocaleCasing(match) as Locale;
}
export function getLocaleFromPathOrDefault(path: string): Locale {