negotiator
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -46,5 +46,5 @@ module.exports = preferredMediaTypes; | ||
function getMediaTypePriority(type, accepted) { | ||
return (accepted.filter(function(a) { | ||
return (accepted.map(function(a) { | ||
return specify(type, a); | ||
}).sort(function (a, b) { | ||
}).filter(Boolean).sort(function (a, b) { | ||
// revsort | ||
@@ -70,11 +70,10 @@ return a.s > b.s ? -1 : 1; | ||
if (spec.params) { | ||
var keys = Object.keys(spec.params); | ||
if (keys.some(function (k) { | ||
var keys = Object.keys(spec.params); | ||
if (keys.length > 0) { | ||
if (keys.every(function (k) { | ||
return spec.params[k] == '*' || spec.params[k] == p.params[k]; | ||
})) { | ||
return null; | ||
s |= 1 | ||
} else { | ||
s |= 1; | ||
return null | ||
} | ||
@@ -81,0 +80,0 @@ } |
{ | ||
"name": "negotiator", | ||
"description": "HTTP content negotiation", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"author": "Federico Romero <federico.romero@outboxlabs.com>", | ||
@@ -22,3 +22,3 @@ "contributors": ["Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"], | ||
"devDependencies": { | ||
"nodeunit": "0.6.x" | ||
"nodeunit": "0.8.x" | ||
}, | ||
@@ -25,0 +25,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
# Negotiator | ||
# Negotiator [![Build Status](https://travis-ci.org/federomero/negotiator.png)](https://travis-ci.org/federomero/negotiator) | ||
@@ -3,0 +3,0 @@ An HTTP content negotiator for node.js written in javascript. |
@@ -70,3 +70,36 @@ (function() { | ||
selected: ['text/plain', 'text/html'] | ||
}, { | ||
accept: 'application/json, */*; q=0.01', | ||
provided: ['text/html', 'application/json'], | ||
selected: ['application/json', 'text/html'] | ||
}, { | ||
accept: 'application/vnd.example;attribute=value', | ||
provided: ['application/vnd.example;attribute=other', 'application/vnd.example;attribute=value'], | ||
selected: ['application/vnd.example;attribute=value'] | ||
}, { | ||
accept: 'application/vnd.example;attribute=other', | ||
provided: ['application/vnd.example', 'application/vnd.example;attribute=other'], | ||
selected: ['application/vnd.example;attribute=other'] | ||
}, { | ||
accept: 'text/html;level=1', | ||
provided: ['text/html;level=1;foo=bar'], | ||
selected: ['text/html;level=1;foo=bar'] | ||
}, { | ||
accept: 'text/html;level=1;foo=bar', | ||
provided: ['text/html;level=1'], | ||
selected: [] | ||
}, { | ||
accept: 'text/html;level=2', | ||
provided: ['text/html;level=1'], | ||
selected: [] | ||
}, { | ||
accept : 'text/html, text/html;level=1;q=0.1', | ||
provided : ['text/html', 'text/html;level=1'], | ||
selected : ['text/html', 'text/html;level=1'] | ||
}, { | ||
accept : 'text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5', | ||
provided : ['text/html;level=1', 'text/html', 'text/html;level=3', 'image/jpeg', 'text/html;level=2', 'text/plain'], | ||
selected : ['text/html;level=1', 'text/html', 'text/html;level=3', 'image/jpeg', 'text/html;level=2', 'text/plain'] | ||
} | ||
]; | ||
@@ -73,0 +106,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30459
17
843