1
0
mirror of synced 2025-12-23 11:54:18 -05:00

fix: detect language error on /_next/data/ input (#22419)

This commit is contained in:
Mike Surowiec
2021-10-26 14:03:47 -07:00
committed by GitHub
parent 5100b5599d
commit e3074d998f
2 changed files with 5 additions and 1 deletions

View File

@@ -36,7 +36,7 @@ function getUserLanguage(browserLanguages) {
// determine language code from a path. Default to en if no valid match
export function getLanguageCodeFromPath(path) {
const maybeLanguage = path.split('/')[path.startsWith('/_next/data/') ? 4 : 1].slice(0, 2)
const maybeLanguage = (path.split('/')[path.startsWith('/_next/data/') ? 4 : 1] || '').slice(0, 2)
return languageCodes.includes(maybeLanguage) ? maybeLanguage : 'en'
}