whatwg-mimetype 2.1.0 → 2.2.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/LICENSE.txt +1 -1
- package/README.md +1 -1
- package/lib/parser.js +28 -27
- package/lib/serializer.js +1 -1
- package/lib/utils.js +2 -2
- package/package.json +5 -5
package/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright © 2017 Domenic Denicola <d@domenic.me>
|
|
1
|
+
Copyright © 2017–2018 Domenic Denicola <d@domenic.me>
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
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 [190c18a](https://github.com/whatwg/mimesniff/commit/190c18af1d81754ff298cfb6fc9e581afdce4d2c).
|
|
28
28
|
|
|
29
29
|
## `MIMEType` API
|
|
30
30
|
|
package/lib/parser.js
CHANGED
|
@@ -72,46 +72,47 @@ module.exports = input => {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
let parameterValue = "";
|
|
75
|
-
if (position
|
|
76
|
-
|
|
77
|
-
++position;
|
|
75
|
+
if (input[position] === "\"") {
|
|
76
|
+
++position;
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
while (true) {
|
|
79
|
+
while (position < input.length && input[position] !== "\"" && input[position] !== "\\") {
|
|
80
|
+
parameterValue += input[position];
|
|
81
|
+
++position;
|
|
82
|
+
}
|
|
84
83
|
|
|
85
|
-
|
|
84
|
+
if (position < input.length && input[position] === "\\") {
|
|
85
|
+
++position;
|
|
86
|
+
if (position < input.length) {
|
|
87
|
+
parameterValue += input[position];
|
|
86
88
|
++position;
|
|
87
|
-
|
|
88
|
-
parameterValue += input[position];
|
|
89
|
-
++position;
|
|
90
|
-
continue;
|
|
91
|
-
} else {
|
|
92
|
-
parameterValue += "\\";
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
89
|
+
continue;
|
|
95
90
|
} else {
|
|
91
|
+
parameterValue += "\\";
|
|
96
92
|
break;
|
|
97
93
|
}
|
|
94
|
+
} else {
|
|
95
|
+
break;
|
|
98
96
|
}
|
|
97
|
+
}
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
while (position < input.length && input[position] !== ";") {
|
|
100
|
+
++position;
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
while (position < input.length && input[position] !== ";") {
|
|
104
|
+
parameterValue += input[position];
|
|
105
|
+
++position;
|
|
106
|
+
}
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
parameterValue = removeTrailingASCIIWhitespace(parameterValue);
|
|
109
|
+
|
|
110
|
+
if (parameterValue === "") {
|
|
111
|
+
continue;
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
if (parameterName.length > 0 &&
|
|
114
|
-
parameterValue.length > 0 &&
|
|
115
116
|
solelyContainsHTTPTokenCodePoints(parameterName) &&
|
|
116
117
|
soleyContainsHTTPQuotedStringTokenCodePoints(parameterValue) &&
|
|
117
118
|
!mimeType.parameters.has(parameterName)) {
|
package/lib/serializer.js
CHANGED
|
@@ -13,7 +13,7 @@ module.exports = mimeType => {
|
|
|
13
13
|
serialization += name;
|
|
14
14
|
serialization += "=";
|
|
15
15
|
|
|
16
|
-
if (!solelyContainsHTTPTokenCodePoints(value)) {
|
|
16
|
+
if (!solelyContainsHTTPTokenCodePoints(value) || value.length === 0) {
|
|
17
17
|
value = value.replace(/(["\\])/g, "\\$1");
|
|
18
18
|
value = `"${value}"`;
|
|
19
19
|
}
|
package/lib/utils.js
CHANGED
|
@@ -13,11 +13,11 @@ exports.isASCIIWhitespaceChar = char => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
exports.solelyContainsHTTPTokenCodePoints = string => {
|
|
16
|
-
return /^[-!#$%&'*+.^_`|~A-Za-z0-9]
|
|
16
|
+
return /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/.test(string);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
exports.soleyContainsHTTPQuotedStringTokenCodePoints = string => {
|
|
20
|
-
return /^[\t\u0020-\u007E\u0080-\u00FF]
|
|
20
|
+
return /^[\t\u0020-\u007E\u0080-\u00FF]*$/.test(string);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
exports.asciiLowercase = string => {
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"http",
|
|
9
9
|
"whatwg"
|
|
10
10
|
],
|
|
11
|
-
"version": "2.
|
|
11
|
+
"version": "2.2.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": "^
|
|
27
|
-
"jest": "^
|
|
26
|
+
"eslint": "^5.5.0",
|
|
27
|
+
"jest": "^23.6.0",
|
|
28
28
|
"printable-string": "^0.3.0",
|
|
29
|
-
"request": "^2.
|
|
30
|
-
"whatwg-encoding": "^1.0.
|
|
29
|
+
"request": "^2.88.0",
|
|
30
|
+
"whatwg-encoding": "^1.0.4"
|
|
31
31
|
},
|
|
32
32
|
"jest": {
|
|
33
33
|
"coverageDirectory": "coverage",
|