add support for 4-letter language codes (ex: zh-TW)

This commit is contained in:
Fred K. Schott 2021-08-01 23:48:53 -07:00
parent 877f9d2702
commit b3270728c2

View file

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