Socket
Socket
Sign inDemoInstall

negotiator

Package Overview
Dependencies
0
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

6

HISTORY.md

@@ -0,1 +1,7 @@

0.5.2 / 2015-05-06
==================
* Fix comparing media types with quoted values
* Fix splitting media types with quoted commas
0.5.1 / 2015-02-14

@@ -2,0 +8,0 @@ ==================

41

lib/mediaType.js

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

function parseAccept(accept) {
var accepts = accept.split(',');
var accepts = splitMediaTypes(accept);

@@ -36,4 +36,10 @@ for (var i = 0, j = 0; i < accepts.length; i++) {

}).reduce(function (set, p) {
set[p[0]] = p[1];
return set
var name = p[0];
var value = p[1];
set[name] = value && value[0] === '"' && value[value.length - 1] === '"'
? value.substr(1, value.length - 2)
: value;
return set;
}, params);

@@ -139,1 +145,30 @@

}
function quoteCount(string) {
var count = 0;
var index = 0;
while ((index = string.indexOf('"', index)) !== -1) {
count++;
index++;
}
return count;
}
function splitMediaTypes(accept) {
var accepts = accept.split(',');
for (var i = 1, j = 0; i < accepts.length; i++) {
if (quoteCount(accepts[j]) % 2 == 0) {
accepts[++j] = accepts[i];
} else {
accepts[j] += ',' + accepts[i];
}
}
// trim accepts
accepts.length = j + 1;
return accepts;
}

12

package.json
{
"name": "negotiator",
"description": "HTTP content negotiation",
"version": "0.5.1",
"version": "0.5.2",
"contributors": [

@@ -21,5 +21,4 @@ "Douglas Christopher Wilson <doug@somethingdoug.com>",

"devDependencies": {
"istanbul": "0.3.5",
"nodeunit": "0.9.0",
"tap": "0.5.0"
"istanbul": "0.3.9",
"mocha": "~1.21.5"
},

@@ -37,5 +36,6 @@ "files": [

"scripts": {
"test": "nodeunit test",
"test-cov": "istanbul cover ./node_modules/nodeunit/bin/nodeunit test"
"test": "mocha --reporter spec --check-leaks --bail test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc