express-middleware
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "express-middleware", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Set of middlewares for Chauffeur-Privé", | ||
@@ -50,4 +50,3 @@ "keywords": [ | ||
"engines": { | ||
"node": ">=6.0.0", | ||
"npm": ">=2.14.7" | ||
"node": ">=6.0.0" | ||
}, | ||
@@ -54,0 +53,0 @@ "bugs": { |
@@ -42,3 +42,3 @@ 'use strict'; | ||
}); | ||
return matchingLanguage ? languageObjectToString(matchingLanguage) : null; | ||
return matchingLanguage || null; | ||
} | ||
@@ -45,0 +45,0 @@ |
@@ -82,2 +82,26 @@ 'use strict'; | ||
it('should match exactly the first language found in the Accept-Language header', function test(done) { | ||
const req = { get: () => 'fr-FR,en-US;q=0.7' }; | ||
const middleware = language({ languages }); | ||
expect(middleware).to.be.instanceof(Function); | ||
middleware(req, null, () => { | ||
expect(req.language).to.equal('fr-FR'); | ||
done(); | ||
}); | ||
}); | ||
it('should match the first language found with a partial matching', function test(done) { | ||
const req = { get: () => 'fr,en-US;q=0.7' }; | ||
const middleware = language({ languages }); | ||
expect(middleware).to.be.instanceof(Function); | ||
middleware(req, null, () => { | ||
expect(req.language).to.equal('fr-FR'); | ||
done(); | ||
}); | ||
}); | ||
it('should throw if languages is not set', function test() { | ||
@@ -84,0 +108,0 @@ expect(() => language({ languages: null })).to.throw(); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
148929
30
4138
2