Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const headerLngs = req.headers['accept-language'].split(',');
const headerLngCodes = headerLngs.map(lng => lng.split(';')[0].trim());
const headerLang = headerLngCodes.find(code => {
return INIT_OPTIONS.localeOptions.find(option => option == code);
});
if (headerLang) {
locale = headerLang;
}
} else {
locale = INIT_OPTIONS.initialLocale || INIT_OPTIONS.fallbackLocale;
}
}
if (locale != null && locale !== currentLocale) {
$locale.set(locale);
}
next();
};
}