Fixes locale parsing edge case (#109)

This commit is contained in:
Chris Anderson 2023-04-01 18:47:49 -05:00 committed by GitHub
parent 0b2020309b
commit 3cca06057d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -85,8 +85,9 @@ export const batch = <T>(arr: T[], size: number) => {
}
export const parseLocale = (locale: string): string | undefined => {
const parts = locale.split('-')
return parts.length === 1 ? locale[0] : locale
return locale.slice(-1) === '-'
? locale.slice(0, -1)
: locale
}
export const partialMatchLocale = (locale1?: string, locale2?: string) => {