Changements dans les modules (nouvelle version Express, mysql, ..)
This commit is contained in:
82
node_modules/negotiator/lib/encoding.js
generated
vendored
82
node_modules/negotiator/lib/encoding.js
generated
vendored
@@ -1,32 +1,5 @@
|
||||
/**
|
||||
* negotiator
|
||||
* Copyright(c) 2012 Isaac Z. Schlueter
|
||||
* Copyright(c) 2014 Federico Romero
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = preferredEncodings;
|
||||
module.exports.preferredEncodings = preferredEncodings;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
|
||||
|
||||
/**
|
||||
* Parse the Accept-Encoding header.
|
||||
* @private
|
||||
*/
|
||||
preferredEncodings.preferredEncodings = preferredEncodings;
|
||||
|
||||
function parseAcceptEncoding(accept) {
|
||||
var accepts = accept.split(',');
|
||||
@@ -61,21 +34,17 @@ function parseAcceptEncoding(accept) {
|
||||
return accepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an encoding from the Accept-Encoding header.
|
||||
* @private
|
||||
*/
|
||||
function parseEncoding(s, i) {
|
||||
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
|
||||
|
||||
function parseEncoding(str, i) {
|
||||
var match = simpleEncodingRegExp.exec(str);
|
||||
if (!match) return null;
|
||||
|
||||
var encoding = match[1];
|
||||
var q = 1;
|
||||
if (match[2]) {
|
||||
var params = match[2].split(';');
|
||||
for (var j = 0; j < params.length; j++) {
|
||||
var p = params[j].trim().split('=');
|
||||
for (var i = 0; i < params.length; i ++) {
|
||||
var p = params[i].trim().split('=');
|
||||
if (p[0] === 'q') {
|
||||
q = parseFloat(p[1]);
|
||||
break;
|
||||
@@ -90,11 +59,6 @@ function parseEncoding(str, i) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority of an encoding.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getEncodingPriority(encoding, accepted, index) {
|
||||
var priority = {o: -1, q: 0, s: 0};
|
||||
|
||||
@@ -109,11 +73,6 @@ function getEncodingPriority(encoding, accepted, index) {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specificity of the encoding.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function specify(encoding, spec, index) {
|
||||
var s = 0;
|
||||
if(spec.encoding.toLowerCase() === encoding.toLowerCase()){
|
||||
@@ -130,20 +89,14 @@ function specify(encoding, spec, index) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the preferred encodings from an Accept-Encoding header.
|
||||
* @public
|
||||
*/
|
||||
|
||||
function preferredEncodings(accept, provided) {
|
||||
var accepts = parseAcceptEncoding(accept || '');
|
||||
|
||||
if (!provided) {
|
||||
// sorted list of all encodings
|
||||
return accepts
|
||||
.filter(isQuality)
|
||||
.sort(compareSpecs)
|
||||
.map(getFullEncoding);
|
||||
return accepts.filter(isQuality).sort(compareSpecs).map(function getEncoding(spec) {
|
||||
return spec.encoding;
|
||||
});
|
||||
}
|
||||
|
||||
var priorities = provided.map(function getPriority(type, index) {
|
||||
@@ -156,29 +109,10 @@ function preferredEncodings(accept, provided) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two specs.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function compareSpecs(a, b) {
|
||||
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full encoding string.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getFullEncoding(spec) {
|
||||
return spec.encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a spec has any quality.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function isQuality(spec) {
|
||||
return spec.q > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user