Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

negotiator

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

negotiator - npm Package Compare versions

Comparing version 0.4.7 to 0.4.8

README.md

19

lib/charset.js

@@ -5,4 +5,4 @@ module.exports = preferredCharsets;

function parseAcceptCharset(accept) {
return accept.split(',').map(function(e) {
return parseCharset(e.trim());
return accept.split(',').map(function(e, i) {
return parseCharset(e.trim(), i);
}).filter(function(e) {

@@ -13,3 +13,3 @@ return e;

function parseCharset(s) {
function parseCharset(s, i) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);

@@ -33,3 +33,4 @@ if (!match) return null;

charset: charset,
q: q
q: q,
i: i
};

@@ -52,3 +53,3 @@ }

var s = 0;
if(spec.charset === charset){
if(spec.charset.toLowerCase() === charset.toLowerCase()){
s |= 1;

@@ -76,7 +77,3 @@ } else if (spec.charset !== '*' ) {

var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
return (pb.q - pa.q) || (pb.s - pa.s) || (pa.i - pb.i);
}).map(function(pair) {

@@ -88,3 +85,3 @@ return pair[0];

// revsort
return a.q < b.q ? 1 : -1;
return (b.q - a.q) || (a.i - b.i);
}).filter(function(type) {

@@ -91,0 +88,0 @@ return type.q > 0;

@@ -8,4 +8,4 @@ module.exports = preferredEncodings;

if (accept) {
acceptableEncodings = accept.split(',').map(function(e) {
return parseEncoding(e.trim());
acceptableEncodings = accept.split(',').map(function(e, i) {
return parseEncoding(e.trim(), i);
});

@@ -43,3 +43,3 @@ } else {

function parseEncoding(s) {
function parseEncoding(s, i) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);

@@ -64,3 +64,4 @@

encoding: encoding,
q: q
q: q,
i: i
};

@@ -83,3 +84,3 @@ }

var s = 0;
if(spec.encoding === encoding){
if(spec.encoding.toLowerCase() === encoding.toLowerCase()){
s |= 1;

@@ -106,7 +107,3 @@ } else if (spec.encoding !== '*' ) {

var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
return (pb.q - pa.q) || (pb.s - pa.s) || (pa.i - pb.i);
}).map(function(pair) {

@@ -118,3 +115,3 @@ return pair[0];

// revsort
return a.q < b.q ? 1 : -1;
return (b.q - a.q) || (a.i - b.i);
}).filter(function(type){

@@ -121,0 +118,0 @@ return type.q > 0;

@@ -5,4 +5,4 @@ module.exports = preferredLanguages;

function parseAcceptLanguage(accept) {
return accept.split(',').map(function(e) {
return parseLanguage(e.trim());
return accept.split(',').map(function(e, i) {
return parseLanguage(e.trim(), i);
}).filter(function(e) {

@@ -13,3 +13,3 @@ return e;

function parseLanguage(s) {
function parseLanguage(s, i) {
var match = s.match(/^\s*(\S+?)(?:-(\S+?))?\s*(?:;(.*))?$/);

@@ -37,2 +37,3 @@ if (!match) return null;

q: q,
i: i,
full: full

@@ -58,7 +59,7 @@ };

var s = 0;
if(spec.full === p.full){
if(spec.full.toLowerCase() === p.full.toLowerCase()){
s |= 4;
} else if (spec.prefix === p.full) {
} else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) {
s |= 2;
} else if (spec.full === p.prefix) {
} else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) {
s |= 1;

@@ -87,7 +88,3 @@ } else if (spec.full !== '*' ) {

var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
return (pb.q - pa.q) || (pb.s - pa.s) || (pa.i - pb.i);
}).map(function(pair) {

@@ -101,3 +98,3 @@ return pair[0];

// revsort
return a.q < b.q ? 1 : -1;
return (b.q - a.q) || (a.i - b.i);
}).filter(function(type) {

@@ -104,0 +101,0 @@ return type.q > 0;

@@ -5,4 +5,4 @@ module.exports = preferredMediaTypes;

function parseAccept(accept) {
return accept.split(',').map(function(e) {
return parseMediaType(e.trim());
return accept.split(',').map(function(e, i) {
return parseMediaType(e.trim(), i);
}).filter(function(e) {

@@ -13,3 +13,3 @@ return e;

function parseMediaType(s) {
function parseMediaType(s, i) {
var match = s.match(/\s*(\S+?)\/([^;\s]+)\s*(?:;(.*))?/);

@@ -43,2 +43,3 @@ if (!match) return null;

q: q,
i: i,
full: full

@@ -68,3 +69,3 @@ };

if(spec.type == p.type) {
if(spec.type.toLowerCase() == p.type.toLowerCase()) {
s |= 4

@@ -75,3 +76,3 @@ } else if(spec.type != '*') {

if(spec.subtype == p.subtype) {
if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) {
s |= 2

@@ -85,3 +86,3 @@ } else if(spec.subtype != '*') {

if (keys.every(function (k) {
return spec.params[k] == '*' || spec.params[k] == p.params[k];
return spec.params[k] == '*' || spec.params[k].toLowerCase() == (p.params[k] || '').toLowerCase();
})) {

@@ -112,7 +113,3 @@ s |= 1

var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
return (pb.q - pa.q) || (pb.s - pa.s) || (pa.i - pb.i);
}).map(function(pair) {

@@ -125,3 +122,3 @@ return pair[0];

// revsort
return a.q < b.q ? 1 : -1;
return (b.q - a.q) || (a.i - b.i);
}).filter(function(type) {

@@ -128,0 +125,0 @@ return type.q > 0;

{
"name": "negotiator",
"description": "HTTP content negotiation",
"version": "0.4.7",
"version": "0.4.8",
"author": "Federico Romero <federico.romero@outboxlabs.com>",
"contributors": ["Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"],
"repository": {
"type": "git",
"url": "git://github.com/federomero/negotiator.git"
},
"repository": "jshttp/negotiator",
"keywords": [

@@ -19,15 +16,19 @@ "http",

],
"engine": "node >= 0.6",
"license": "MIT",
"devDependencies": {
"istanbul": "~0.3.2",
"nodeunit": "0.8.x"
},
"scripts": {
"test": "nodeunit test"
"test": "nodeunit test",
"test-cov": "istanbul cover ./node_modules/nodeunit/bin/nodeunit test"
},
"optionalDependencies": {},
"engines": {
"node": "*"
"node": ">= 0.6"
},
"main": "lib/negotiator.js"
"main": "lib/negotiator.js",
"files": [
"lib",
"LICENSE"
]
}

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