node-red-contrib-web-worldmap 5.0.5 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +1 -1
- package/node_modules/accepts/node_modules/negotiator/HISTORY.md +108 -0
- package/node_modules/{body-parser/node_modules/bytes → accepts/node_modules/negotiator}/LICENSE +3 -2
- package/node_modules/accepts/node_modules/negotiator/README.md +203 -0
- package/node_modules/accepts/node_modules/negotiator/index.js +82 -0
- package/node_modules/accepts/node_modules/negotiator/lib/charset.js +169 -0
- package/node_modules/accepts/node_modules/negotiator/lib/encoding.js +184 -0
- package/node_modules/accepts/node_modules/negotiator/lib/language.js +179 -0
- package/node_modules/accepts/node_modules/negotiator/lib/mediaType.js +294 -0
- package/node_modules/accepts/node_modules/negotiator/package.json +42 -0
- package/node_modules/bytes/History.md +15 -0
- package/node_modules/bytes/Readme.md +45 -18
- package/node_modules/bytes/index.js +15 -4
- package/node_modules/bytes/package.json +7 -4
- package/node_modules/compression/HISTORY.md +15 -0
- package/node_modules/compression/README.md +4 -6
- package/node_modules/compression/index.js +3 -8
- package/node_modules/compression/package.json +19 -19
- package/node_modules/negotiator/HISTORY.md +5 -0
- package/node_modules/negotiator/README.md +9 -0
- package/node_modules/negotiator/index.js +4 -4
- package/node_modules/negotiator/lib/encoding.js +26 -5
- package/node_modules/negotiator/lib/mediaType.js +3 -3
- package/node_modules/negotiator/package.json +1 -1
- package/node_modules/object-inspect/CHANGELOG.md +12 -0
- package/node_modules/object-inspect/index.js +17 -3
- package/node_modules/object-inspect/package.json +6 -6
- package/node_modules/object-inspect/test/quoteStyle.js +9 -0
- package/node_modules/safe-buffer/index.js +3 -0
- package/node_modules/safe-buffer/package.json +18 -4
- package/node_modules/tslib/modules/index.d.ts +1 -0
- package/node_modules/tslib/modules/index.js +2 -0
- package/node_modules/tslib/package.json +1 -1
- package/node_modules/tslib/tslib.d.ts +7 -0
- package/node_modules/tslib/tslib.es6.js +24 -1
- package/node_modules/tslib/tslib.es6.mjs +24 -1
- package/node_modules/tslib/tslib.js +56 -1
- package/package.json +1 -1
- package/worldmap/worldmap.js +3 -0
- package/worldmap.js +2 -2
- package/node_modules/body-parser/node_modules/bytes/History.md +0 -97
- package/node_modules/body-parser/node_modules/bytes/Readme.md +0 -152
- package/node_modules/body-parser/node_modules/bytes/index.js +0 -170
- package/node_modules/body-parser/node_modules/bytes/package.json +0 -42
- package/node_modules/content-disposition/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/content-disposition/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/content-disposition/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/content-disposition/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/content-disposition/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/express/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/express/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/express/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/express/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/express/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/raw-body/node_modules/bytes/History.md +0 -97
- package/node_modules/raw-body/node_modules/bytes/LICENSE +0 -23
- package/node_modules/raw-body/node_modules/bytes/Readme.md +0 -152
- package/node_modules/raw-body/node_modules/bytes/index.js +0 -170
- package/node_modules/raw-body/node_modules/bytes/package.json +0 -42
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* negotiator
|
|
3
|
+
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
4
|
+
* Copyright(c) 2014 Federico Romero
|
|
5
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Module exports.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
module.exports = preferredEncodings;
|
|
17
|
+
module.exports.preferredEncodings = preferredEncodings;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Module variables.
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Parse the Accept-Encoding header.
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function parseAcceptEncoding(accept) {
|
|
32
|
+
var accepts = accept.split(',');
|
|
33
|
+
var hasIdentity = false;
|
|
34
|
+
var minQuality = 1;
|
|
35
|
+
|
|
36
|
+
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
37
|
+
var encoding = parseEncoding(accepts[i].trim(), i);
|
|
38
|
+
|
|
39
|
+
if (encoding) {
|
|
40
|
+
accepts[j++] = encoding;
|
|
41
|
+
hasIdentity = hasIdentity || specify('identity', encoding);
|
|
42
|
+
minQuality = Math.min(minQuality, encoding.q || 1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!hasIdentity) {
|
|
47
|
+
/*
|
|
48
|
+
* If identity doesn't explicitly appear in the accept-encoding header,
|
|
49
|
+
* it's added to the list of acceptable encoding with the lowest q
|
|
50
|
+
*/
|
|
51
|
+
accepts[j++] = {
|
|
52
|
+
encoding: 'identity',
|
|
53
|
+
q: minQuality,
|
|
54
|
+
i: i
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// trim accepts
|
|
59
|
+
accepts.length = j;
|
|
60
|
+
|
|
61
|
+
return accepts;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Parse an encoding from the Accept-Encoding header.
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
function parseEncoding(str, i) {
|
|
70
|
+
var match = simpleEncodingRegExp.exec(str);
|
|
71
|
+
if (!match) return null;
|
|
72
|
+
|
|
73
|
+
var encoding = match[1];
|
|
74
|
+
var q = 1;
|
|
75
|
+
if (match[2]) {
|
|
76
|
+
var params = match[2].split(';');
|
|
77
|
+
for (var j = 0; j < params.length; j++) {
|
|
78
|
+
var p = params[j].trim().split('=');
|
|
79
|
+
if (p[0] === 'q') {
|
|
80
|
+
q = parseFloat(p[1]);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
encoding: encoding,
|
|
88
|
+
q: q,
|
|
89
|
+
i: i
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get the priority of an encoding.
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
function getEncodingPriority(encoding, accepted, index) {
|
|
99
|
+
var priority = {o: -1, q: 0, s: 0};
|
|
100
|
+
|
|
101
|
+
for (var i = 0; i < accepted.length; i++) {
|
|
102
|
+
var spec = specify(encoding, accepted[i], index);
|
|
103
|
+
|
|
104
|
+
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
|
105
|
+
priority = spec;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return priority;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get the specificity of the encoding.
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
function specify(encoding, spec, index) {
|
|
118
|
+
var s = 0;
|
|
119
|
+
if(spec.encoding.toLowerCase() === encoding.toLowerCase()){
|
|
120
|
+
s |= 1;
|
|
121
|
+
} else if (spec.encoding !== '*' ) {
|
|
122
|
+
return null
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
i: index,
|
|
127
|
+
o: spec.i,
|
|
128
|
+
q: spec.q,
|
|
129
|
+
s: s
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get the preferred encodings from an Accept-Encoding header.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
function preferredEncodings(accept, provided) {
|
|
139
|
+
var accepts = parseAcceptEncoding(accept || '');
|
|
140
|
+
|
|
141
|
+
if (!provided) {
|
|
142
|
+
// sorted list of all encodings
|
|
143
|
+
return accepts
|
|
144
|
+
.filter(isQuality)
|
|
145
|
+
.sort(compareSpecs)
|
|
146
|
+
.map(getFullEncoding);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var priorities = provided.map(function getPriority(type, index) {
|
|
150
|
+
return getEncodingPriority(type, accepts, index);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// sorted list of accepted encodings
|
|
154
|
+
return priorities.filter(isQuality).sort(compareSpecs).map(function getEncoding(priority) {
|
|
155
|
+
return provided[priorities.indexOf(priority)];
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Compare two specs.
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
function compareSpecs(a, b) {
|
|
165
|
+
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Get full encoding string.
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
function getFullEncoding(spec) {
|
|
174
|
+
return spec.encoding;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Check if a spec has any quality.
|
|
179
|
+
* @private
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
function isQuality(spec) {
|
|
183
|
+
return spec.q > 0;
|
|
184
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* negotiator
|
|
3
|
+
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
4
|
+
* Copyright(c) 2014 Federico Romero
|
|
5
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Module exports.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
module.exports = preferredLanguages;
|
|
17
|
+
module.exports.preferredLanguages = preferredLanguages;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Module variables.
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var simpleLanguageRegExp = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Parse the Accept-Language header.
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function parseAcceptLanguage(accept) {
|
|
32
|
+
var accepts = accept.split(',');
|
|
33
|
+
|
|
34
|
+
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
35
|
+
var language = parseLanguage(accepts[i].trim(), i);
|
|
36
|
+
|
|
37
|
+
if (language) {
|
|
38
|
+
accepts[j++] = language;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// trim accepts
|
|
43
|
+
accepts.length = j;
|
|
44
|
+
|
|
45
|
+
return accepts;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parse a language from the Accept-Language header.
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function parseLanguage(str, i) {
|
|
54
|
+
var match = simpleLanguageRegExp.exec(str);
|
|
55
|
+
if (!match) return null;
|
|
56
|
+
|
|
57
|
+
var prefix = match[1]
|
|
58
|
+
var suffix = match[2]
|
|
59
|
+
var full = prefix
|
|
60
|
+
|
|
61
|
+
if (suffix) full += "-" + suffix;
|
|
62
|
+
|
|
63
|
+
var q = 1;
|
|
64
|
+
if (match[3]) {
|
|
65
|
+
var params = match[3].split(';')
|
|
66
|
+
for (var j = 0; j < params.length; j++) {
|
|
67
|
+
var p = params[j].split('=');
|
|
68
|
+
if (p[0] === 'q') q = parseFloat(p[1]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
prefix: prefix,
|
|
74
|
+
suffix: suffix,
|
|
75
|
+
q: q,
|
|
76
|
+
i: i,
|
|
77
|
+
full: full
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get the priority of a language.
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
function getLanguagePriority(language, accepted, index) {
|
|
87
|
+
var priority = {o: -1, q: 0, s: 0};
|
|
88
|
+
|
|
89
|
+
for (var i = 0; i < accepted.length; i++) {
|
|
90
|
+
var spec = specify(language, accepted[i], index);
|
|
91
|
+
|
|
92
|
+
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
|
93
|
+
priority = spec;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return priority;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get the specificity of the language.
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
function specify(language, spec, index) {
|
|
106
|
+
var p = parseLanguage(language)
|
|
107
|
+
if (!p) return null;
|
|
108
|
+
var s = 0;
|
|
109
|
+
if(spec.full.toLowerCase() === p.full.toLowerCase()){
|
|
110
|
+
s |= 4;
|
|
111
|
+
} else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) {
|
|
112
|
+
s |= 2;
|
|
113
|
+
} else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) {
|
|
114
|
+
s |= 1;
|
|
115
|
+
} else if (spec.full !== '*' ) {
|
|
116
|
+
return null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
i: index,
|
|
121
|
+
o: spec.i,
|
|
122
|
+
q: spec.q,
|
|
123
|
+
s: s
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get the preferred languages from an Accept-Language header.
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
function preferredLanguages(accept, provided) {
|
|
133
|
+
// RFC 2616 sec 14.4: no header = *
|
|
134
|
+
var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || '');
|
|
135
|
+
|
|
136
|
+
if (!provided) {
|
|
137
|
+
// sorted list of all languages
|
|
138
|
+
return accepts
|
|
139
|
+
.filter(isQuality)
|
|
140
|
+
.sort(compareSpecs)
|
|
141
|
+
.map(getFullLanguage);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
var priorities = provided.map(function getPriority(type, index) {
|
|
145
|
+
return getLanguagePriority(type, accepts, index);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// sorted list of accepted languages
|
|
149
|
+
return priorities.filter(isQuality).sort(compareSpecs).map(function getLanguage(priority) {
|
|
150
|
+
return provided[priorities.indexOf(priority)];
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Compare two specs.
|
|
156
|
+
* @private
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
function compareSpecs(a, b) {
|
|
160
|
+
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get full language string.
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
function getFullLanguage(spec) {
|
|
169
|
+
return spec.full;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Check if a spec has any quality.
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
function isQuality(spec) {
|
|
178
|
+
return spec.q > 0;
|
|
179
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* negotiator
|
|
3
|
+
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
4
|
+
* Copyright(c) 2014 Federico Romero
|
|
5
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Module exports.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
module.exports = preferredMediaTypes;
|
|
17
|
+
module.exports.preferredMediaTypes = preferredMediaTypes;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Module variables.
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Parse the Accept header.
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function parseAccept(accept) {
|
|
32
|
+
var accepts = splitMediaTypes(accept);
|
|
33
|
+
|
|
34
|
+
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
35
|
+
var mediaType = parseMediaType(accepts[i].trim(), i);
|
|
36
|
+
|
|
37
|
+
if (mediaType) {
|
|
38
|
+
accepts[j++] = mediaType;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// trim accepts
|
|
43
|
+
accepts.length = j;
|
|
44
|
+
|
|
45
|
+
return accepts;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parse a media type from the Accept header.
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function parseMediaType(str, i) {
|
|
54
|
+
var match = simpleMediaTypeRegExp.exec(str);
|
|
55
|
+
if (!match) return null;
|
|
56
|
+
|
|
57
|
+
var params = Object.create(null);
|
|
58
|
+
var q = 1;
|
|
59
|
+
var subtype = match[2];
|
|
60
|
+
var type = match[1];
|
|
61
|
+
|
|
62
|
+
if (match[3]) {
|
|
63
|
+
var kvps = splitParameters(match[3]).map(splitKeyValuePair);
|
|
64
|
+
|
|
65
|
+
for (var j = 0; j < kvps.length; j++) {
|
|
66
|
+
var pair = kvps[j];
|
|
67
|
+
var key = pair[0].toLowerCase();
|
|
68
|
+
var val = pair[1];
|
|
69
|
+
|
|
70
|
+
// get the value, unwrapping quotes
|
|
71
|
+
var value = val && val[0] === '"' && val[val.length - 1] === '"'
|
|
72
|
+
? val.substr(1, val.length - 2)
|
|
73
|
+
: val;
|
|
74
|
+
|
|
75
|
+
if (key === 'q') {
|
|
76
|
+
q = parseFloat(value);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// store parameter
|
|
81
|
+
params[key] = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
type: type,
|
|
87
|
+
subtype: subtype,
|
|
88
|
+
params: params,
|
|
89
|
+
q: q,
|
|
90
|
+
i: i
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get the priority of a media type.
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
function getMediaTypePriority(type, accepted, index) {
|
|
100
|
+
var priority = {o: -1, q: 0, s: 0};
|
|
101
|
+
|
|
102
|
+
for (var i = 0; i < accepted.length; i++) {
|
|
103
|
+
var spec = specify(type, accepted[i], index);
|
|
104
|
+
|
|
105
|
+
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
|
106
|
+
priority = spec;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return priority;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get the specificity of the media type.
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
function specify(type, spec, index) {
|
|
119
|
+
var p = parseMediaType(type);
|
|
120
|
+
var s = 0;
|
|
121
|
+
|
|
122
|
+
if (!p) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if(spec.type.toLowerCase() == p.type.toLowerCase()) {
|
|
127
|
+
s |= 4
|
|
128
|
+
} else if(spec.type != '*') {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) {
|
|
133
|
+
s |= 2
|
|
134
|
+
} else if(spec.subtype != '*') {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var keys = Object.keys(spec.params);
|
|
139
|
+
if (keys.length > 0) {
|
|
140
|
+
if (keys.every(function (k) {
|
|
141
|
+
return spec.params[k] == '*' || (spec.params[k] || '').toLowerCase() == (p.params[k] || '').toLowerCase();
|
|
142
|
+
})) {
|
|
143
|
+
s |= 1
|
|
144
|
+
} else {
|
|
145
|
+
return null
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
i: index,
|
|
151
|
+
o: spec.i,
|
|
152
|
+
q: spec.q,
|
|
153
|
+
s: s,
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get the preferred media types from an Accept header.
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
function preferredMediaTypes(accept, provided) {
|
|
163
|
+
// RFC 2616 sec 14.2: no header = */*
|
|
164
|
+
var accepts = parseAccept(accept === undefined ? '*/*' : accept || '');
|
|
165
|
+
|
|
166
|
+
if (!provided) {
|
|
167
|
+
// sorted list of all types
|
|
168
|
+
return accepts
|
|
169
|
+
.filter(isQuality)
|
|
170
|
+
.sort(compareSpecs)
|
|
171
|
+
.map(getFullType);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
var priorities = provided.map(function getPriority(type, index) {
|
|
175
|
+
return getMediaTypePriority(type, accepts, index);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// sorted list of accepted types
|
|
179
|
+
return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) {
|
|
180
|
+
return provided[priorities.indexOf(priority)];
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Compare two specs.
|
|
186
|
+
* @private
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
function compareSpecs(a, b) {
|
|
190
|
+
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get full type string.
|
|
195
|
+
* @private
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
function getFullType(spec) {
|
|
199
|
+
return spec.type + '/' + spec.subtype;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Check if a spec has any quality.
|
|
204
|
+
* @private
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
function isQuality(spec) {
|
|
208
|
+
return spec.q > 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Count the number of quotes in a string.
|
|
213
|
+
* @private
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
function quoteCount(string) {
|
|
217
|
+
var count = 0;
|
|
218
|
+
var index = 0;
|
|
219
|
+
|
|
220
|
+
while ((index = string.indexOf('"', index)) !== -1) {
|
|
221
|
+
count++;
|
|
222
|
+
index++;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return count;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Split a key value pair.
|
|
230
|
+
* @private
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
function splitKeyValuePair(str) {
|
|
234
|
+
var index = str.indexOf('=');
|
|
235
|
+
var key;
|
|
236
|
+
var val;
|
|
237
|
+
|
|
238
|
+
if (index === -1) {
|
|
239
|
+
key = str;
|
|
240
|
+
} else {
|
|
241
|
+
key = str.substr(0, index);
|
|
242
|
+
val = str.substr(index + 1);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return [key, val];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Split an Accept header into media types.
|
|
250
|
+
* @private
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
function splitMediaTypes(accept) {
|
|
254
|
+
var accepts = accept.split(',');
|
|
255
|
+
|
|
256
|
+
for (var i = 1, j = 0; i < accepts.length; i++) {
|
|
257
|
+
if (quoteCount(accepts[j]) % 2 == 0) {
|
|
258
|
+
accepts[++j] = accepts[i];
|
|
259
|
+
} else {
|
|
260
|
+
accepts[j] += ',' + accepts[i];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// trim accepts
|
|
265
|
+
accepts.length = j + 1;
|
|
266
|
+
|
|
267
|
+
return accepts;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Split a string of parameters.
|
|
272
|
+
* @private
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
function splitParameters(str) {
|
|
276
|
+
var parameters = str.split(';');
|
|
277
|
+
|
|
278
|
+
for (var i = 1, j = 0; i < parameters.length; i++) {
|
|
279
|
+
if (quoteCount(parameters[j]) % 2 == 0) {
|
|
280
|
+
parameters[++j] = parameters[i];
|
|
281
|
+
} else {
|
|
282
|
+
parameters[j] += ';' + parameters[i];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// trim parameters
|
|
287
|
+
parameters.length = j + 1;
|
|
288
|
+
|
|
289
|
+
for (var i = 0; i < parameters.length; i++) {
|
|
290
|
+
parameters[i] = parameters[i].trim();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return parameters;
|
|
294
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "negotiator",
|
|
3
|
+
"description": "HTTP content negotiation",
|
|
4
|
+
"version": "0.6.3",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
7
|
+
"Federico Romero <federico.romero@outboxlabs.com>",
|
|
8
|
+
"Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"http",
|
|
13
|
+
"content negotiation",
|
|
14
|
+
"accept",
|
|
15
|
+
"accept-language",
|
|
16
|
+
"accept-encoding",
|
|
17
|
+
"accept-charset"
|
|
18
|
+
],
|
|
19
|
+
"repository": "jshttp/negotiator",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"eslint": "7.32.0",
|
|
22
|
+
"eslint-plugin-markdown": "2.2.1",
|
|
23
|
+
"mocha": "9.1.3",
|
|
24
|
+
"nyc": "15.1.0"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"lib/",
|
|
28
|
+
"HISTORY.md",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"index.js",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">= 0.6"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"test": "mocha --reporter spec --check-leaks --bail test/",
|
|
39
|
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
|
40
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
3.1.2 / 2022-01-27
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* Fix return value for un-parsable strings
|
|
5
|
+
|
|
6
|
+
3.1.1 / 2021-11-15
|
|
7
|
+
==================
|
|
8
|
+
|
|
9
|
+
* Fix "thousandsSeparator" incorrecting formatting fractional part
|
|
10
|
+
|
|
11
|
+
3.1.0 / 2019-01-22
|
|
12
|
+
==================
|
|
13
|
+
|
|
14
|
+
* Add petabyte (`pb`) support
|
|
15
|
+
|
|
1
16
|
3.0.0 / 2017-08-31
|
|
2
17
|
==================
|
|
3
18
|
|