New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

accept-language-parser

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accept-language-parser - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

12

index.js
var regex = /((([a-zA-Z]+(-[a-zA-Z0-9]+){0,2})|\*)(;q=[0-1](\.[0-9]+)?)?)*/g;
var isString = function(s){
return typeof(s) === 'string';
};
module.exports.parse = function(al){

@@ -32,3 +36,5 @@ var strings = (al || "").match(regex);

var accept = this.parse(acceptLanguage);
if(isString(acceptLanguage)){
acceptLanguage = this.parse(acceptLanguage);
}

@@ -46,4 +52,4 @@ var supported = supportedLanguages.map(function(support){

for (var i = 0; i < accept.length; i++) {
var lang = accept[i];
for (var i = 0; i < acceptLanguage.length; i++) {
var lang = acceptLanguage[i];
var langCode = lang.code.toLowerCase();

@@ -50,0 +56,0 @@ var langRegion = lang.region ? lang.region.toLowerCase() : lang.region;

{
"name": "accept-language-parser",
"version": "1.3.0",
"version": "1.4.0",
"description": "Parse the accept-language header from a HTTP request",
"main": "index.js",
"scripts": {
"test": "grunt test"
"mocha": "mocha tests/",
"jshint": "jshint index.js tests/",
"test": "npm run jshint && npm run mocha"
},

@@ -25,8 +27,6 @@ "repository": {

"devDependencies": {
"grunt": "^0.4.4",
"grunt-cli": "^0.1.13",
"grunt-contrib-jshint": "^1.0.0",
"grunt-mocha-test": "^0.10.0",
"jshint": "^2.9.4",
"mocha": "^3.2.0",
"should": "^11.0.0"
}
}

@@ -8,5 +8,4 @@ accept-language-parser

dependencies: none
installation:
### Installation:

@@ -17,4 +16,6 @@ ```

parse usage:
### API
#### parser.parse(acceptLanguageHeader)
```

@@ -47,4 +48,6 @@ var parser = require('accept-language-parser');

pick usage:
#### parser.pick(supportedLangugagesArray, acceptLanguageHeader)
*Alias*: parser.pick(supportedLanguagesArray, parsedAcceptLanguageHeader)
```

@@ -67,3 +70,6 @@ var parser = require('accept-language-parser');

npm install
grunt test
npm test
```
### License
MIT

@@ -9,10 +9,10 @@ var parser = require("../index.js");

if(actual.script || expected.script){
actual.script.should.eql(expected.script)
actual.script.should.eql(expected.script);
}
if(actual.region || expected.region){
actual.region.should.eql(expected.region)
actual.region.should.eql(expected.region);
}
actual.quality.should.eql(expected.quality);
}
};

@@ -104,2 +104,7 @@ describe('accept-language#parse()', function(){

it('should pick a specific regional language when accept-language is parsed', function(){
var result = parser.pick(['en-US', 'fr-CA'], parser.parse('fr-CA,fr;q=0.2,en-US;q=0.6,en;q=0.4,*;q=0.5'));
assert.equal(result, 'fr-CA');
});
it('should pick a specific script (if specified)', function(){

@@ -106,0 +111,0 @@ var result = parser.pick(['zh-Hant-cn', 'zh-cn'], 'zh-Hant-cn,zh-cn;q=0.6,zh;q=0.4');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc