Trim langs from accept header

This commit is contained in:
simojenki
2021-08-14 17:47:59 +10:00
parent 0d21c34243
commit ab73569393
2 changed files with 10 additions and 1 deletions

View File

@@ -107,7 +107,7 @@ export const randomLang = () => _.shuffle(["en-US", "nl-NL"])[0]!;
export const asLANGs = (acceptLanguageHeader: string | undefined) => {
const z = acceptLanguageHeader?.split(";")[0];
return z && z != "" ? z.split(",") : [];
return z && z != "" ? z.split(",").map(it => it.trim()) : [];
};
export type I8N = (...langs: string[]) => Lang;