accept-language-parser
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -43,4 +43,8 @@ var regex = /((([a-zA-Z]+(-[a-zA-Z]+)?)|\*)(;q=[0-1](\.[0-9]+)?)?)*/g; | ||
var lang = accept[i]; | ||
var langCode = lang.code.toLowerCase(); | ||
var langRegion = lang.region ? lang.region.toLowerCase() : lang.region; | ||
for (var j = 0; j < supported.length; j++) { | ||
if (lang.code === supported[j].code && (!lang.region || lang.region === supported[j].region)) { | ||
var supportedCode = supported[j].code.toLowerCase(); | ||
var supportedRegion = supported[j].region ? supported[j].region.toLowerCase() : supported[j].region; | ||
if (langCode === supportedCode && (!langRegion || langRegion === supportedRegion)) { | ||
return supportedLanguages[j]; | ||
@@ -47,0 +51,0 @@ } |
{ | ||
"name": "accept-language-parser", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Parse the accept-language header from a HTTP request", | ||
@@ -28,5 +28,5 @@ "main": "index.js", | ||
"grunt-mocha-test": "^0.10.0", | ||
"should": "^3.2.0", | ||
"should": "^9.0.0", | ||
"grunt-contrib-jshint": "^0.9.2" | ||
} | ||
} |
@@ -81,2 +81,7 @@ var parser = require("../index.js"); | ||
it('should pick proper language regardless of casing', function(){ | ||
var result = parser.pick(['eN-Us', 'Fr-cA'], 'fR-Ca,fr;q=0.2,en-US;q=0.6,en;q=0.4,*;q=0.5'); | ||
assert.equal(result.toLowerCase(), 'fr-ca'); | ||
}); | ||
it('should pick a specific language', function(){ | ||
@@ -83,0 +88,0 @@ var result = parser.pick(['en', 'fr-CA'], 'ja-JP,ja;1=0.5,en;q=0.2'); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11338
170
1