This commit is contained in:
Felix Roos 2022-12-20 19:50:32 +01:00
parent 7efaff4f6f
commit d0013f55a2
13 changed files with 338 additions and 356 deletions

View file

@ -4,7 +4,7 @@ export { KNOWN_LANGUAGES, KNOWN_LANGUAGE_CODES };
export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//;
export function getLanguageFromURL(pathname: string) {
const langCodeMatch = pathname.match(langPathRegex);
const langCode = langCodeMatch ? langCodeMatch[1] : 'en';
return langCode as typeof KNOWN_LANGUAGE_CODES[number];
const langCodeMatch = pathname.match(langPathRegex);
const langCode = langCodeMatch ? langCodeMatch[1] : 'en';
return langCode as typeof KNOWN_LANGUAGE_CODES[number];
}