@d1g1tal/media-type 6.0.1 → 6.0.3
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 +17 -0
- package/LICENSE +12 -9
- package/README.md +1 -1
- package/dist/media-type.d.ts +131 -0
- package/dist/media-type.js +284 -0
- package/dist/media-type.js.map +7 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [6.0.3](https://github.com/D1g1talEntr0py/media-type/compare/v6.0.2...v6.0.3) (2026-03-02)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* add prepublishOnly due to stupid human mistake (8864b012f879a91fe9aa363b6d0c842563d92331)
|
|
6
|
+
|
|
7
|
+
## [6.0.2](https://github.com/D1g1talEntr0py/media-type/compare/v6.0.1...v6.0.2) (2026-03-02)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* version bump due to Claude mistake. Oops! (1752b078a6fe162e3f7837cdf02af4d62c9f3d05)
|
|
12
|
+
|
|
13
|
+
### Documentation
|
|
14
|
+
|
|
15
|
+
* fixed license file (e52439d82791806dac633ffae1e7c6891677e40e)
|
|
16
|
+
* fixed license file, again (44dd9ccc6e6be8cb8b2ea29c7bb44f6daebf98fc)
|
|
17
|
+
|
|
1
18
|
## [6.0.1](https://github.com/D1g1talEntr0py/media-type/compare/v6.0.0...v6.0.1) (2026-03-01)
|
|
2
19
|
|
|
3
20
|
### Bug Fixes
|
package/LICENSE
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
ISC License
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
that the above copyright notice and this permission notice appear in all copies.
|
|
3
|
+
Copyright (c) 2023, Jason DiMeo
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
10
|
-
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@d1g1tal/media-type)
|
|
5
5
|
[](https://github.com/D1g1talEntr0py/media-type/actions/workflows/ci.yml)
|
|
6
6
|
[](https://codecov.io/gh/D1g1talEntr0py/media-type)
|
|
7
|
-
[](https://github.com/D1g1talEntr0py/media-type/blob/main/LICENSE)
|
|
7
|
+
[](https://github.com/D1g1talEntr0py/media-type/blob/main/LICENSE)
|
|
8
8
|
[](https://nodejs.org)
|
|
9
9
|
[](https://www.typescriptlang.org/)
|
|
10
10
|
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class representing the parameters for a media type record.
|
|
3
|
+
* This class extends a JavaScript Map<string, string>.
|
|
4
|
+
*
|
|
5
|
+
* However, MediaTypeParameters methods will always interpret their arguments
|
|
6
|
+
* as appropriate for media types, so parameter names will be lowercased,
|
|
7
|
+
* and attempting to set invalid characters will throw an Error.
|
|
8
|
+
*
|
|
9
|
+
* @see https://mimesniff.spec.whatwg.org
|
|
10
|
+
* @author D1g1talEntr0py <jason.dimeo@gmail.com>
|
|
11
|
+
*/
|
|
12
|
+
declare class MediaTypeParameters extends Map<string, string> {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new MediaTypeParameters instance.
|
|
15
|
+
*
|
|
16
|
+
* @param entries An array of [ name, value ] tuples.
|
|
17
|
+
*/
|
|
18
|
+
constructor(entries?: Iterable<[string, string]>);
|
|
19
|
+
/**
|
|
20
|
+
* Indicates whether the supplied name and value are valid media type parameters.
|
|
21
|
+
*
|
|
22
|
+
* @param name The name of the media type parameter to validate.
|
|
23
|
+
* @param value The media type parameter value to validate.
|
|
24
|
+
* @returns true if the media type parameter is valid, false otherwise.
|
|
25
|
+
*/
|
|
26
|
+
static isValid(name: string, value: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the media type parameter value for the supplied name.
|
|
29
|
+
*
|
|
30
|
+
* @param name The name of the media type parameter to retrieve.
|
|
31
|
+
* @returns The media type parameter value.
|
|
32
|
+
*/
|
|
33
|
+
get(name: string): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Indicates whether the media type parameter with the specified name exists or not.
|
|
36
|
+
*
|
|
37
|
+
* @param name The name of the media type parameter to check.
|
|
38
|
+
* @returns true if the media type parameter exists, false otherwise.
|
|
39
|
+
*/
|
|
40
|
+
has(name: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Adds a new media type parameter using the specified name and value to the MediaTypeParameters.
|
|
43
|
+
* If an parameter with the same name already exists, the parameter will be updated.
|
|
44
|
+
*
|
|
45
|
+
* @param name The name of the media type parameter to set.
|
|
46
|
+
* @param value The media type parameter value.
|
|
47
|
+
* @returns This instance.
|
|
48
|
+
*/
|
|
49
|
+
set(name: string, value: string): this;
|
|
50
|
+
/**
|
|
51
|
+
* Removes the media type parameter using the specified name.
|
|
52
|
+
*
|
|
53
|
+
* @param name The name of the media type parameter to delete.
|
|
54
|
+
* @returns true if the parameter existed and has been removed, or false if the parameter does not exist.
|
|
55
|
+
*/
|
|
56
|
+
delete(name: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Returns a string representation of the media type parameters.
|
|
59
|
+
*
|
|
60
|
+
* @returns The string representation of the media type parameters.
|
|
61
|
+
*/
|
|
62
|
+
toString(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the name of this class.
|
|
65
|
+
*
|
|
66
|
+
* @returns The name of this class.
|
|
67
|
+
*/
|
|
68
|
+
get [Symbol.toStringTag](): string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Class used to parse media types.
|
|
73
|
+
* @see https://mimesniff.spec.whatwg.org/#understanding-mime-types
|
|
74
|
+
*/
|
|
75
|
+
declare class MediaType {
|
|
76
|
+
private readonly _type;
|
|
77
|
+
private readonly _subtype;
|
|
78
|
+
private readonly _parameters;
|
|
79
|
+
/**
|
|
80
|
+
* Create a new MediaType instance from a string representation.
|
|
81
|
+
* @param mediaType The media type to parse.
|
|
82
|
+
* @param parameters Optional parameters.
|
|
83
|
+
*/
|
|
84
|
+
constructor(mediaType: string, parameters?: Record<string, string>);
|
|
85
|
+
/**
|
|
86
|
+
* Parses a media type string.
|
|
87
|
+
* @param mediaType The media type to parse.
|
|
88
|
+
* @returns The parsed media type or null if the mediaType cannot be parsed.
|
|
89
|
+
*/
|
|
90
|
+
static parse(mediaType: string): MediaType | null;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the type.
|
|
93
|
+
* @returns The type.
|
|
94
|
+
*/
|
|
95
|
+
get type(): string;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the subtype.
|
|
98
|
+
* @returns The subtype.
|
|
99
|
+
*/
|
|
100
|
+
get subtype(): string;
|
|
101
|
+
/**
|
|
102
|
+
* Gets the media type essence (type/subtype).
|
|
103
|
+
* @returns The media type without any parameters
|
|
104
|
+
*/
|
|
105
|
+
get essence(): string;
|
|
106
|
+
/**
|
|
107
|
+
* Gets the parameters.
|
|
108
|
+
* @returns The media type parameters.
|
|
109
|
+
*/
|
|
110
|
+
get parameters(): MediaTypeParameters;
|
|
111
|
+
/**
|
|
112
|
+
* Checks if the media type matches the specified type.
|
|
113
|
+
*
|
|
114
|
+
* @param mediaType The media type to check.
|
|
115
|
+
* @returns true if the media type matches the specified type, false otherwise.
|
|
116
|
+
*/
|
|
117
|
+
matches(mediaType: MediaType | string): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Gets the serialized version of the media type.
|
|
120
|
+
*
|
|
121
|
+
* @returns The serialized media type.
|
|
122
|
+
*/
|
|
123
|
+
toString(): string;
|
|
124
|
+
/**
|
|
125
|
+
* Gets the name of the class.
|
|
126
|
+
* @returns The class name
|
|
127
|
+
*/
|
|
128
|
+
get [Symbol.toStringTag](): string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { MediaType, MediaTypeParameters };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
var httpTokenCodePoints = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;
|
|
3
|
+
|
|
4
|
+
// src/media-type-parameters.ts
|
|
5
|
+
var matcher = /(["\\])/ug;
|
|
6
|
+
var httpQuotedStringTokenCodePoints = /^[\t\u0020-\u007E\u0080-\u00FF]*$/u;
|
|
7
|
+
var MediaTypeParameters = class _MediaTypeParameters extends Map {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new MediaTypeParameters instance.
|
|
10
|
+
*
|
|
11
|
+
* @param entries An array of [ name, value ] tuples.
|
|
12
|
+
*/
|
|
13
|
+
constructor(entries = []) {
|
|
14
|
+
super(entries);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Indicates whether the supplied name and value are valid media type parameters.
|
|
18
|
+
*
|
|
19
|
+
* @param name The name of the media type parameter to validate.
|
|
20
|
+
* @param value The media type parameter value to validate.
|
|
21
|
+
* @returns true if the media type parameter is valid, false otherwise.
|
|
22
|
+
*/
|
|
23
|
+
static isValid(name, value) {
|
|
24
|
+
return httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the media type parameter value for the supplied name.
|
|
28
|
+
*
|
|
29
|
+
* @param name The name of the media type parameter to retrieve.
|
|
30
|
+
* @returns The media type parameter value.
|
|
31
|
+
*/
|
|
32
|
+
get(name) {
|
|
33
|
+
return super.get(name.toLowerCase());
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Indicates whether the media type parameter with the specified name exists or not.
|
|
37
|
+
*
|
|
38
|
+
* @param name The name of the media type parameter to check.
|
|
39
|
+
* @returns true if the media type parameter exists, false otherwise.
|
|
40
|
+
*/
|
|
41
|
+
has(name) {
|
|
42
|
+
return super.has(name.toLowerCase());
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Adds a new media type parameter using the specified name and value to the MediaTypeParameters.
|
|
46
|
+
* If an parameter with the same name already exists, the parameter will be updated.
|
|
47
|
+
*
|
|
48
|
+
* @param name The name of the media type parameter to set.
|
|
49
|
+
* @param value The media type parameter value.
|
|
50
|
+
* @returns This instance.
|
|
51
|
+
*/
|
|
52
|
+
set(name, value) {
|
|
53
|
+
if (!_MediaTypeParameters.isValid(name, value)) {
|
|
54
|
+
throw new Error(`Invalid media type parameter name/value: ${name}/${value}`);
|
|
55
|
+
}
|
|
56
|
+
super.set(name.toLowerCase(), value);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Removes the media type parameter using the specified name.
|
|
61
|
+
*
|
|
62
|
+
* @param name The name of the media type parameter to delete.
|
|
63
|
+
* @returns true if the parameter existed and has been removed, or false if the parameter does not exist.
|
|
64
|
+
*/
|
|
65
|
+
delete(name) {
|
|
66
|
+
return super.delete(name.toLowerCase());
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns a string representation of the media type parameters.
|
|
70
|
+
*
|
|
71
|
+
* @returns The string representation of the media type parameters.
|
|
72
|
+
*/
|
|
73
|
+
toString() {
|
|
74
|
+
return Array.from(this).map(([name, value]) => `;${name}=${!value || !httpTokenCodePoints.test(value) ? `"${value.replace(matcher, "\\$1")}"` : value}`).join("");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns the name of this class.
|
|
78
|
+
*
|
|
79
|
+
* @returns The name of this class.
|
|
80
|
+
*/
|
|
81
|
+
get [Symbol.toStringTag]() {
|
|
82
|
+
return "MediaTypeParameters";
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/media-type-parser.ts
|
|
87
|
+
var whitespaceChars = /* @__PURE__ */ new Set([" ", " ", "\n", "\r"]);
|
|
88
|
+
var trailingWhitespace = /[ \t\n\r]+$/u;
|
|
89
|
+
var leadingAndTrailingWhitespace = /^[ \t\n\r]+|[ \t\n\r]+$/ug;
|
|
90
|
+
var MediaTypeParser = class _MediaTypeParser {
|
|
91
|
+
/**
|
|
92
|
+
* Function to parse a media type.
|
|
93
|
+
* @param input The media type to parse
|
|
94
|
+
* @returns An object populated with the parsed media type properties and any parameters.
|
|
95
|
+
*/
|
|
96
|
+
static parse(input) {
|
|
97
|
+
input = input.replace(leadingAndTrailingWhitespace, "");
|
|
98
|
+
let position = 0;
|
|
99
|
+
const [type, typeEnd] = _MediaTypeParser.collect(input, position, ["/"]);
|
|
100
|
+
position = typeEnd;
|
|
101
|
+
if (!type.length || position >= input.length || !httpTokenCodePoints.test(type)) {
|
|
102
|
+
throw new TypeError(_MediaTypeParser.generateErrorMessage("type", type));
|
|
103
|
+
}
|
|
104
|
+
++position;
|
|
105
|
+
const [subtype, subtypeEnd] = _MediaTypeParser.collect(input, position, [";"], true, true);
|
|
106
|
+
position = subtypeEnd;
|
|
107
|
+
if (!subtype.length || !httpTokenCodePoints.test(subtype)) {
|
|
108
|
+
throw new TypeError(_MediaTypeParser.generateErrorMessage("subtype", subtype));
|
|
109
|
+
}
|
|
110
|
+
const parameters = new MediaTypeParameters();
|
|
111
|
+
while (position < input.length) {
|
|
112
|
+
++position;
|
|
113
|
+
while (whitespaceChars.has(input[position])) {
|
|
114
|
+
++position;
|
|
115
|
+
}
|
|
116
|
+
let name;
|
|
117
|
+
[name, position] = _MediaTypeParser.collect(input, position, [";", "="], false);
|
|
118
|
+
if (position >= input.length || input[position] === ";") {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
++position;
|
|
122
|
+
let value;
|
|
123
|
+
if (input[position] === '"') {
|
|
124
|
+
[value, position] = _MediaTypeParser.collectHttpQuotedString(input, position);
|
|
125
|
+
while (position < input.length && input[position] !== ";") {
|
|
126
|
+
++position;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
[value, position] = _MediaTypeParser.collect(input, position, [";"], false, true);
|
|
130
|
+
if (!value) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (name && MediaTypeParameters.isValid(name, value) && !parameters.has(name)) {
|
|
135
|
+
parameters.set(name, value);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return { type, subtype, parameters };
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Gets the name of this class.
|
|
142
|
+
* @returns The string tag of this class.
|
|
143
|
+
*/
|
|
144
|
+
get [Symbol.toStringTag]() {
|
|
145
|
+
return "MediaTypeParser";
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Collects characters from `input` starting at `pos` until a stop character is found.
|
|
149
|
+
* @param input The input string.
|
|
150
|
+
* @param pos The starting position.
|
|
151
|
+
* @param stopChars Characters that end collection.
|
|
152
|
+
* @param lowerCase Whether to ASCII-lowercase the result.
|
|
153
|
+
* @param trim Whether to strip trailing HTTP whitespace.
|
|
154
|
+
* @returns A tuple of the collected string and the updated position.
|
|
155
|
+
*/
|
|
156
|
+
static collect(input, pos, stopChars, lowerCase = true, trim = false) {
|
|
157
|
+
let result = "";
|
|
158
|
+
for (const { length } = input; pos < length && !stopChars.includes(input[pos]); pos++) {
|
|
159
|
+
result += input[pos];
|
|
160
|
+
}
|
|
161
|
+
if (lowerCase) {
|
|
162
|
+
result = result.toLowerCase();
|
|
163
|
+
}
|
|
164
|
+
if (trim) {
|
|
165
|
+
result = result.replace(trailingWhitespace, "");
|
|
166
|
+
}
|
|
167
|
+
return [result, pos];
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Collects all the HTTP quoted strings.
|
|
171
|
+
* This variant only implements it with the extract-value flag set.
|
|
172
|
+
* @param input The string to process.
|
|
173
|
+
* @param position The starting position.
|
|
174
|
+
* @returns An array that includes the resulting string and updated position.
|
|
175
|
+
*/
|
|
176
|
+
static collectHttpQuotedString(input, position) {
|
|
177
|
+
let value = "";
|
|
178
|
+
for (let length = input.length, char; ++position < length; ) {
|
|
179
|
+
if ((char = input[position]) === '"') {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
value += char == "\\" && ++position < length ? input[position] : char;
|
|
183
|
+
}
|
|
184
|
+
return [value, position];
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Generates an error message.
|
|
188
|
+
* @param component The component name.
|
|
189
|
+
* @param value The component value.
|
|
190
|
+
* @returns The error message.
|
|
191
|
+
*/
|
|
192
|
+
static generateErrorMessage(component, value) {
|
|
193
|
+
return `Invalid ${component} "${value}": only HTTP token code points are valid.`;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/media-type.ts
|
|
198
|
+
var MediaType = class _MediaType {
|
|
199
|
+
_type;
|
|
200
|
+
_subtype;
|
|
201
|
+
_parameters;
|
|
202
|
+
/**
|
|
203
|
+
* Create a new MediaType instance from a string representation.
|
|
204
|
+
* @param mediaType The media type to parse.
|
|
205
|
+
* @param parameters Optional parameters.
|
|
206
|
+
*/
|
|
207
|
+
constructor(mediaType, parameters = {}) {
|
|
208
|
+
if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
|
|
209
|
+
throw new TypeError("The parameters argument must be an object");
|
|
210
|
+
}
|
|
211
|
+
({ type: this._type, subtype: this._subtype, parameters: this._parameters } = MediaTypeParser.parse(mediaType));
|
|
212
|
+
for (const [name, value] of Object.entries(parameters)) {
|
|
213
|
+
this._parameters.set(name, value);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Parses a media type string.
|
|
218
|
+
* @param mediaType The media type to parse.
|
|
219
|
+
* @returns The parsed media type or null if the mediaType cannot be parsed.
|
|
220
|
+
*/
|
|
221
|
+
static parse(mediaType) {
|
|
222
|
+
try {
|
|
223
|
+
return new _MediaType(mediaType);
|
|
224
|
+
} catch {
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Gets the type.
|
|
230
|
+
* @returns The type.
|
|
231
|
+
*/
|
|
232
|
+
get type() {
|
|
233
|
+
return this._type;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Gets the subtype.
|
|
237
|
+
* @returns The subtype.
|
|
238
|
+
*/
|
|
239
|
+
get subtype() {
|
|
240
|
+
return this._subtype;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Gets the media type essence (type/subtype).
|
|
244
|
+
* @returns The media type without any parameters
|
|
245
|
+
*/
|
|
246
|
+
get essence() {
|
|
247
|
+
return `${this._type}/${this._subtype}`;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Gets the parameters.
|
|
251
|
+
* @returns The media type parameters.
|
|
252
|
+
*/
|
|
253
|
+
get parameters() {
|
|
254
|
+
return this._parameters;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Checks if the media type matches the specified type.
|
|
258
|
+
*
|
|
259
|
+
* @param mediaType The media type to check.
|
|
260
|
+
* @returns true if the media type matches the specified type, false otherwise.
|
|
261
|
+
*/
|
|
262
|
+
matches(mediaType) {
|
|
263
|
+
return typeof mediaType === "string" ? this.essence.includes(mediaType) : this._type === mediaType._type && this._subtype === mediaType._subtype;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Gets the serialized version of the media type.
|
|
267
|
+
*
|
|
268
|
+
* @returns The serialized media type.
|
|
269
|
+
*/
|
|
270
|
+
toString() {
|
|
271
|
+
return `${this.essence}${this._parameters.toString()}`;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Gets the name of the class.
|
|
275
|
+
* @returns The class name
|
|
276
|
+
*/
|
|
277
|
+
get [Symbol.toStringTag]() {
|
|
278
|
+
return "MediaType";
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
export {
|
|
282
|
+
MediaType
|
|
283
|
+
};
|
|
284
|
+
//# sourceMappingURL=media-type.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils.ts", "../src/media-type-parameters.ts", "../src/media-type-parser.ts", "../src/media-type.ts"],
|
|
4
|
+
"sourcesContent": ["export const httpTokenCodePoints: RegExp = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;", "import { httpTokenCodePoints } from './utils.js';\n\nconst matcher: RegExp = /([\"\\\\])/ug;\nconst httpQuotedStringTokenCodePoints: RegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]*$/u;\n\n/**\n * Class representing the parameters for a media type record.\n * This class extends a JavaScript Map<string, string>.\n *\n * However, MediaTypeParameters methods will always interpret their arguments\n * as appropriate for media types, so parameter names will be lowercased,\n * and attempting to set invalid characters will throw an Error.\n *\n * @see https://mimesniff.spec.whatwg.org\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParameters extends Map<string, string> {\n\t/**\n\t * Create a new MediaTypeParameters instance.\n\t *\n\t * @param entries An array of [ name, value ] tuples.\n\t */\n\tconstructor(entries: Iterable<[string, string]> = []) {\n\t\tsuper(entries);\n\t}\n\n\t/**\n\t * Indicates whether the supplied name and value are valid media type parameters.\n\t *\n\t * @param name The name of the media type parameter to validate.\n\t * @param value The media type parameter value to validate.\n\t * @returns true if the media type parameter is valid, false otherwise.\n\t */\n\tstatic isValid(name: string, value: string): boolean {\n\t\treturn httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);\n\t}\n\n\t/**\n\t * Gets the media type parameter value for the supplied name.\n\t *\n\t * @param name The name of the media type parameter to retrieve.\n\t * @returns The media type parameter value.\n\t */\n\toverride get(name: string): string | undefined {\n\t\treturn super.get(name.toLowerCase());\n\t}\n\n\t/**\n\t * Indicates whether the media type parameter with the specified name exists or not.\n\t *\n\t * @param name The name of the media type parameter to check.\n\t * @returns true if the media type parameter exists, false otherwise.\n\t */\n\toverride has(name: string): boolean {\n\t\treturn super.has(name.toLowerCase());\n\t}\n\n\t/**\n\t * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.\n\t * If an parameter with the same name already exists, the parameter will be updated.\n\t *\n\t * @param name The name of the media type parameter to set.\n\t * @param value The media type parameter value.\n\t * @returns This instance.\n\t */\n\toverride set(name: string, value: string): this {\n\t\tif (!MediaTypeParameters.isValid(name, value)) {\n\t\t\tthrow new Error(`Invalid media type parameter name/value: ${name}/${value}`);\n\t\t}\n\n\t\tsuper.set(name.toLowerCase(), value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the media type parameter using the specified name.\n\t *\n\t * @param name The name of the media type parameter to delete.\n\t * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.\n\t */\n\toverride delete(name: string): boolean {\n\t\treturn super.delete(name.toLowerCase());\n\t}\n\n\t/**\n\t * Returns a string representation of the media type parameters.\n\t *\n\t * @returns The string representation of the media type parameters.\n\t */\n\toverride toString(): string {\n\t\treturn Array.from(this).map(([ name, value ]) => `;${name}=${!value || !httpTokenCodePoints.test(value) ? `\"${value.replace(matcher, '\\\\$1')}\"` : value}`).join('');\n\t}\n\n\t/**\n\t * Returns the name of this class.\n\t *\n\t * @returns The name of this class.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParameters';\n\t}\n}", "import { MediaTypeParameters } from './media-type-parameters.js';\nimport { httpTokenCodePoints } from './utils.js';\n\nconst whitespaceChars = new Set([' ', '\\t', '\\n', '\\r']);\nconst trailingWhitespace: RegExp = /[ \\t\\n\\r]+$/u;\nconst leadingAndTrailingWhitespace: RegExp = /^[ \\t\\n\\r]+|[ \\t\\n\\r]+$/ug;\n\nexport interface MediaTypeComponent {\n\tposition?: number;\n\tinput: string;\n\tlowerCase?: boolean;\n\ttrim?: boolean;\n}\n\nexport interface ParsedMediaType {\n\ttype: string;\n\tsubtype: string;\n\tparameters: MediaTypeParameters;\n}\n\n/**\n * Parser for media types.\n * @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParser {\n\t/**\n\t * Function to parse a media type.\n\t * @param input The media type to parse\n\t * @returns An object populated with the parsed media type properties and any parameters.\n\t */\n\tstatic parse(input: string): ParsedMediaType {\n\t\tinput = input.replace(leadingAndTrailingWhitespace, '');\n\n\t\tlet position = 0;\n\t\tconst [ type, typeEnd ] = MediaTypeParser.collect(input, position, ['/']);\n\t\tposition = typeEnd;\n\n\t\tif (!type.length || position >= input.length || !httpTokenCodePoints.test(type)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('type', type));\n\t\t}\n\n\t\t++position; // Skip \"/\"\n\t\tconst [ subtype, subtypeEnd ] = MediaTypeParser.collect(input, position, [';'], true, true);\n\t\tposition = subtypeEnd;\n\n\t\tif (!subtype.length || !httpTokenCodePoints.test(subtype)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('subtype', subtype));\n\t\t}\n\n\t\tconst parameters = new MediaTypeParameters();\n\n\t\twhile (position < input.length) {\n\t\t\t++position; // Skip \";\"\n\t\t\twhile (whitespaceChars.has(input[position]!)) { ++position }\n\n\t\t\tlet name: string;\n\t\t\t[name, position] = MediaTypeParser.collect(input, position, [';', '='], false);\n\n\t\t\tif (position >= input.length || input[position] === ';') { continue }\n\n\t\t\t++position; // Skip \"=\"\n\n\t\t\tlet value: string;\n\t\t\tif (input[position] === '\"') {\n\t\t\t\t[ value, position ] = MediaTypeParser.collectHttpQuotedString(input, position);\n\t\t\t\twhile (position < input.length && input[position] !== ';') { ++position }\n\t\t\t} else {\n\t\t\t\t[ value, position ] = MediaTypeParser.collect(input, position, [';'], false, true);\n\t\t\t\tif (!value) { continue }\n\t\t\t}\n\n\t\t\tif (name && MediaTypeParameters.isValid(name, value) && !parameters.has(name)) {\n\t\t\t\tparameters.set(name, value);\n\t\t\t}\n\t\t}\n\n\t\treturn { type, subtype, parameters };\n\t}\n\n\t/**\n\t * Gets the name of this class.\n\t * @returns The string tag of this class.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParser';\n\t}\n\n\t/**\n\t * Collects characters from `input` starting at `pos` until a stop character is found.\n\t * @param input The input string.\n\t * @param pos The starting position.\n\t * @param stopChars Characters that end collection.\n\t * @param lowerCase Whether to ASCII-lowercase the result.\n\t * @param trim Whether to strip trailing HTTP whitespace.\n\t * @returns A tuple of the collected string and the updated position.\n\t */\n\tprivate static collect(input: string, pos: number, stopChars: string[], lowerCase = true, trim = false): [string, number] {\n\t\tlet result = '';\n\t\tfor (const { length } = input; pos < length && !stopChars.includes(input[pos]!); pos++) {\n\t\t\tresult += input[pos];\n\t\t}\n\n\t\tif (lowerCase) { result = result.toLowerCase() }\n\t\tif (trim) { result = result.replace(trailingWhitespace, '') }\n\n\t\treturn [result, pos];\n\t}\n\n\t/**\n\t * Collects all the HTTP quoted strings.\n\t * This variant only implements it with the extract-value flag set.\n\t * @param input The string to process.\n\t * @param position The starting position.\n\t * @returns An array that includes the resulting string and updated position.\n\t */\n\tprivate static collectHttpQuotedString(input: string, position: number): [string, number] {\n\t\tlet value = '';\n\n\t\tfor (let length = input.length, char; ++position < length;) {\n\t\t\tif ((char = input[position]) === '\"') { break }\n\n\t\t\tvalue += char == '\\\\' && ++position < length ? input[position] : char;\n\t\t}\n\n\t\treturn [ value, position ];\n\t}\n\n\t/**\n\t * Generates an error message.\n\t * @param component The component name.\n\t * @param value The component value.\n\t * @returns The error message.\n\t */\n\tprivate static generateErrorMessage(component: string, value: string): string {\n\t\treturn `Invalid ${component} \"${value}\": only HTTP token code points are valid.`;\n\t}\n}", "import { MediaTypeParser } from './media-type-parser.js';\nimport { MediaTypeParameters } from './media-type-parameters.js';\n\n/**\n * Class used to parse media types.\n * @see https://mimesniff.spec.whatwg.org/#understanding-mime-types\n */\nexport class MediaType {\n\tprivate readonly _type: string;\n\tprivate readonly _subtype: string;\n\tprivate readonly _parameters: MediaTypeParameters;\n\n\t/**\n\t * Create a new MediaType instance from a string representation.\n\t * @param mediaType The media type to parse.\n\t * @param parameters Optional parameters.\n\t */\n\tconstructor(mediaType: string, parameters: Record<string, string> = {}) {\n\t\tif (parameters === null || typeof parameters !== 'object' || Array.isArray(parameters)) {\n\t\t\tthrow new TypeError('The parameters argument must be an object');\n\t\t}\n\n\t\t({ type: this._type, subtype: this._subtype, parameters: this._parameters } = MediaTypeParser.parse(mediaType));\n\n\t\tfor (const [ name, value ] of Object.entries(parameters)) { this._parameters.set(name, value) }\n\t}\n\n\t/**\n\t * Parses a media type string.\n\t * @param mediaType The media type to parse.\n\t * @returns The parsed media type or null if the mediaType cannot be parsed.\n\t */\n\tstatic parse(mediaType: string): MediaType | null {\n\t\ttry {\n\t\t\treturn new MediaType(mediaType);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the type.\n\t * @returns The type.\n\t */\n\tget type(): string {\n\t\treturn this._type;\n\t}\n\n\t/**\n\t * Gets the subtype.\n\t * @returns The subtype.\n\t */\n\tget subtype(): string {\n\t\treturn this._subtype;\n\t}\n\n\t/**\n\t * Gets the media type essence (type/subtype).\n\t * @returns The media type without any parameters\n\t */\n\tget essence(): string {\n\t\treturn `${this._type}/${this._subtype}`;\n\t}\n\n\t/**\n\t * Gets the parameters.\n\t * @returns The media type parameters.\n\t */\n\tget parameters(): MediaTypeParameters {\n\t\treturn this._parameters;\n\t}\n\n\t/**\n\t * Checks if the media type matches the specified type.\n\t *\n\t * @param mediaType The media type to check.\n\t * @returns true if the media type matches the specified type, false otherwise.\n\t */\n\tmatches(mediaType: MediaType | string): boolean {\n\t\treturn typeof mediaType === 'string' ? this.essence.includes(mediaType) : this._type === mediaType._type && this._subtype === mediaType._subtype;\n\t}\n\n\t/**\n\t * Gets the serialized version of the media type.\n\t *\n\t * @returns The serialized media type.\n\t */\n\ttoString(): string {\n\t\treturn `${this.essence}${this._parameters.toString()}`;\n\t}\n\n\t/**\n\t * Gets the name of the class.\n\t * @returns The class name\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaType';\n\t}\n}"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,sBAA8B;;;ACE3C,IAAM,UAAkB;AACxB,IAAM,kCAA0C;AAazC,IAAM,sBAAN,MAAM,6BAA4B,IAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5D,YAAY,UAAsC,CAAC,GAAG;AACrD,UAAM,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAO,QAAQ,MAAc,OAAwB;AACpD,WAAO,oBAAoB,KAAK,IAAI,KAAK,gCAAgC,KAAK,KAAK;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQS,IAAI,MAAkC;AAC9C,WAAO,MAAM,IAAI,KAAK,YAAY,CAAC;AAAA,EACpC;AAAA;AAAA;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@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d1g1tal/media-type",
|
|
3
3
|
"description": "Parses, serializes, and manipulates media types, according to the WHATWG MIME Sniffing Standard",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.3",
|
|
5
5
|
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
|
6
6
|
"maintainers": [
|
|
7
7
|
{
|
|
@@ -59,15 +59,16 @@
|
|
|
59
59
|
"test:ui": "vitest run --ui",
|
|
60
60
|
"test:coverage": "vitest run --coverage",
|
|
61
61
|
"lint": "eslint",
|
|
62
|
-
"pretest": "node tests/scripts/get-latest-platform-tests.ts"
|
|
62
|
+
"pretest": "node tests/scripts/get-latest-platform-tests.ts",
|
|
63
|
+
"prepublishOnly": "pnpm lint && pnpm build"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
|
-
"@d1g1tal/tsbuild": "^1.3.
|
|
66
|
+
"@d1g1tal/tsbuild": "^1.3.2",
|
|
66
67
|
"@eslint/js": "^10.0.1",
|
|
67
68
|
"@types/node": "^25.3.3",
|
|
68
69
|
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
69
70
|
"@typescript-eslint/parser": "^8.56.1",
|
|
70
|
-
"@typescript/lib-dom": "npm:@types/web@^0.0.
|
|
71
|
+
"@typescript/lib-dom": "npm:@types/web@^0.0.339",
|
|
71
72
|
"@vitest/coverage-v8": "4.0.18",
|
|
72
73
|
"@vitest/ui": "^4.0.18",
|
|
73
74
|
"eslint": "^10.0.2",
|