Skip to content

Commit

Permalink
use parseMimeType in normalizeType
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosc90 committed Oct 10, 2022
1 parent d8b9a1e commit c18129f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions ext/web/09_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
MathMax,
MathMin,
ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest,
StringPrototypeCharAt,
StringPrototypeToLowerCase,
StringPrototypeSlice,
Symbol,
SymbolFor,
TypedArrayPrototypeSet,
TypeError,
Uint8Array,
} = window.__bootstrap.primordials;
const mimesniff = window.__bootstrap.mimesniff;
const consoleInternal = window.__bootstrap.console;

// TODO(lucacasonato): this needs to not be hardcoded and instead depend on
Expand Down Expand Up @@ -144,11 +143,8 @@
* @returns {string}
*/
function normalizeType(str) {
let normalizedType = str;
if (!RegExpPrototypeTest(/^[\x20-\x7E]*$/, str)) {
normalizedType = "";
}
return StringPrototypeToLowerCase(normalizedType);
const mime = mimesniff.parseMimeType(str);
return mime !== null ? mimesniff.serializeMimeType(mime) : "";
}

/**
Expand Down

0 comments on commit c18129f

Please sign in to comment.