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

View file

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