whatwg-mimetype 2.2.0 → 2.3.0
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/README.md +1 -1
- package/lib/parser.js +7 -7
- package/lib/utils.js +6 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ console.assert(mimeType.isXML() === false);
|
|
|
24
24
|
|
|
25
25
|
Parsing is a fairly complex process; see [the specification](https://mimesniff.spec.whatwg.org/#parsing-a-mime-type) for details (and similarly [for serialization](https://mimesniff.spec.whatwg.org/#serializing-a-mime-type)).
|
|
26
26
|
|
|
27
|
-
This package's algorithms conform to those of the WHATWG [MIME Sniffing Standard](https://mimesniff.spec.whatwg.org/), and is aligned up to commit [
|
|
27
|
+
This package's algorithms conform to those of the WHATWG [MIME Sniffing Standard](https://mimesniff.spec.whatwg.org/), and is aligned up to commit [126286a](https://github.com/whatwg/mimesniff/commit/126286ab2dcf3e2d541349ed93539a88bf394ad5).
|
|
28
28
|
|
|
29
29
|
## `MIMEType` API
|
|
30
30
|
|
package/lib/parser.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
removeLeadingAndTrailingHTTPWhitespace,
|
|
4
|
+
removeTrailingHTTPWhitespace,
|
|
5
|
+
isHTTPWhitespaceChar,
|
|
6
6
|
solelyContainsHTTPTokenCodePoints,
|
|
7
7
|
soleyContainsHTTPQuotedStringTokenCodePoints,
|
|
8
8
|
asciiLowercase
|
|
9
9
|
} = require("./utils.js");
|
|
10
10
|
|
|
11
11
|
module.exports = input => {
|
|
12
|
-
input =
|
|
12
|
+
input = removeLeadingAndTrailingHTTPWhitespace(input);
|
|
13
13
|
|
|
14
14
|
let position = 0;
|
|
15
15
|
let type = "";
|
|
@@ -35,7 +35,7 @@ module.exports = input => {
|
|
|
35
35
|
++position;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
subtype =
|
|
38
|
+
subtype = removeTrailingHTTPWhitespace(subtype);
|
|
39
39
|
|
|
40
40
|
if (subtype.length === 0 || !solelyContainsHTTPTokenCodePoints(subtype)) {
|
|
41
41
|
return null;
|
|
@@ -51,7 +51,7 @@ module.exports = input => {
|
|
|
51
51
|
// Skip past ";"
|
|
52
52
|
++position;
|
|
53
53
|
|
|
54
|
-
while (
|
|
54
|
+
while (isHTTPWhitespaceChar(input[position])) {
|
|
55
55
|
++position;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -105,7 +105,7 @@ module.exports = input => {
|
|
|
105
105
|
++position;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
parameterValue =
|
|
108
|
+
parameterValue = removeTrailingHTTPWhitespace(parameterValue);
|
|
109
109
|
|
|
110
110
|
if (parameterValue === "") {
|
|
111
111
|
continue;
|
package/lib/utils.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports.
|
|
4
|
-
return string.replace(/^[ \t\n\
|
|
3
|
+
exports.removeLeadingAndTrailingHTTPWhitespace = string => {
|
|
4
|
+
return string.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
exports.
|
|
8
|
-
return string.replace(/[ \t\n\
|
|
7
|
+
exports.removeTrailingHTTPWhitespace = string => {
|
|
8
|
+
return string.replace(/[ \t\n\r]+$/, "");
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
exports.
|
|
12
|
-
return char === " " || char === "\t" || char === "\n" || char === "\
|
|
11
|
+
exports.isHTTPWhitespaceChar = char => {
|
|
12
|
+
return char === " " || char === "\t" || char === "\n" || char === "\r";
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
exports.solelyContainsHTTPTokenCodePoints = string => {
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"http",
|
|
9
9
|
"whatwg"
|
|
10
10
|
],
|
|
11
|
-
"version": "2.
|
|
11
|
+
"version": "2.3.0",
|
|
12
12
|
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": "jsdom/whatwg-mimetype",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"pretest": "node scripts/get-latest-platform-tests.js"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"eslint": "^5.
|
|
26
|
+
"eslint": "^5.9.0",
|
|
27
27
|
"jest": "^23.6.0",
|
|
28
28
|
"printable-string": "^0.3.0",
|
|
29
29
|
"request": "^2.88.0",
|
|
30
|
-
"whatwg-encoding": "^1.0.
|
|
30
|
+
"whatwg-encoding": "^1.0.5"
|
|
31
31
|
},
|
|
32
32
|
"jest": {
|
|
33
33
|
"coverageDirectory": "coverage",
|