(input)
| 4449 | } |
| 4450 | __name(percentDecode, "percentDecode"); |
| 4451 | function parseMIMEType(input) { |
| 4452 | input = removeHTTPWhitespace(input, true, true); |
| 4453 | const position = { position: 0 }; |
| 4454 | const type = collectASequenceOfCodePointsFast( |
| 4455 | "/", |
| 4456 | input, |
| 4457 | position |
| 4458 | ); |
| 4459 | if (type.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(type)) { |
| 4460 | return "failure"; |
| 4461 | } |
| 4462 | if (position.position >= input.length) { |
| 4463 | return "failure"; |
| 4464 | } |
| 4465 | position.position++; |
| 4466 | let subtype = collectASequenceOfCodePointsFast( |
| 4467 | ";", |
| 4468 | input, |
| 4469 | position |
| 4470 | ); |
| 4471 | subtype = removeHTTPWhitespace(subtype, false, true); |
| 4472 | if (subtype.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(subtype)) { |
| 4473 | return "failure"; |
| 4474 | } |
| 4475 | const typeLowercase = type.toLowerCase(); |
| 4476 | const subtypeLowercase = subtype.toLowerCase(); |
| 4477 | const mimeType = { |
| 4478 | type: typeLowercase, |
| 4479 | subtype: subtypeLowercase, |
| 4480 | /** @type {Map<string, string>} */ |
| 4481 | parameters: /* @__PURE__ */ new Map(), |
| 4482 | // https://mimesniff.spec.whatwg.org/#mime-type-essence |
| 4483 | essence: `${typeLowercase}/${subtypeLowercase}` |
| 4484 | }; |
| 4485 | while (position.position < input.length) { |
| 4486 | position.position++; |
| 4487 | collectASequenceOfCodePoints( |
| 4488 | // https://fetch.spec.whatwg.org/#http-whitespace |
| 4489 | (char) => HTTP_WHITESPACE_REGEX.test(char), |
| 4490 | input, |
| 4491 | position |
| 4492 | ); |
| 4493 | let parameterName = collectASequenceOfCodePoints( |
| 4494 | (char) => char !== ";" && char !== "=", |
| 4495 | input, |
| 4496 | position |
| 4497 | ); |
| 4498 | parameterName = parameterName.toLowerCase(); |
| 4499 | if (position.position < input.length) { |
| 4500 | if (input[position.position] === ";") { |
| 4501 | continue; |
| 4502 | } |
| 4503 | position.position++; |
| 4504 | } |
| 4505 | if (position.position >= input.length) { |
| 4506 | break; |
| 4507 | } |
| 4508 | let parameterValue = null; |
no test coverage detected