fix: locale match error (#115)

This commit is contained in:
Joel 2023-05-20 17:12:12 +08:00 committed by GitHub
parent 8fc2663693
commit 96809108ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,11 @@ export const getLocale = (request: NextRequest): Locale => {
}
// match locale
const matchedLocale = match(languages, locales, i18n.defaultLocale) as Locale
let matchedLocale:Locale = i18n.defaultLocale
try {
// If languages is ['*'], Error would happen in match function.
matchedLocale = match(languages, locales, i18n.defaultLocale) as Locale
} catch(e) {}
return matchedLocale
}