default accept-language to en-US when regexp does not match

This commit is contained in:
Danny Coates 2019-03-13 11:30:24 -07:00
parent 45d9bdb577
commit e702022d7f
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
1 changed files with 1 additions and 1 deletions

View File

@ -24,7 +24,7 @@ module.exports = function(req, res, next) {
req.language = 'en-US';
return next();
}
const langs = header.replace(/\s/g, '').match(acceptLanguages);
const langs = header.replace(/\s/g, '').match(acceptLanguages) || ['en-US'];
const preferred = langs
.map(l => {
const parts = l.split(';');