File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1898,6 +1898,10 @@ console.log(JSON.stringify(myMIMES));
18981898
18991899### ` MIMEType.parse(string) `
19001900
1901+ <!--
1902+ added: REPLACEME
1903+ -->
1904+
19011905* ` string ` {string} The input MIME to parse
19021906* Returns: {MIMEType|null}
19031907
Original file line number Diff line number Diff line change @@ -117,13 +117,8 @@ function dataURLProcessor(dataURL) {
117117 // mimeType.
118118 // 14. If mimeTypeRecord is failure, then set
119119 // mimeTypeRecord to text/plain;charset=US-ASCII.
120- let mimeTypeRecord ;
121-
122- try {
123- mimeTypeRecord = new MIMEType ( mimeType ) ;
124- } catch {
125- mimeTypeRecord = new MIMEType ( 'text/plain;charset=US-ASCII' ) ;
126- }
120+ const mimeTypeRecord = MIMEType . parse ( mimeType ) ||
121+ new MIMEType ( 'text/plain;charset=US-ASCII' ) ;
127122
128123 // 15. Return a new data: URL struct whose MIME
129124 // type is mimeTypeRecord and body is body.
Original file line number Diff line number Diff line change @@ -52,16 +52,9 @@ function getNextRequestId() {
5252} ;
5353
5454function sniffMimeType ( contentType ) {
55- let mimeType ;
56- let charset ;
57- try {
58- const mimeTypeObj = new MIMEType ( contentType ) ;
59- mimeType = StringPrototypeToLowerCase ( mimeTypeObj . essence || '' ) ;
60- charset = StringPrototypeToLowerCase ( mimeTypeObj . params . get ( 'charset' ) || '' ) ;
61- } catch {
62- mimeType = '' ;
63- charset = '' ;
64- }
55+ const mimeTypeObj = MIMEType . parse ( contentType ) ;
56+ const mimeType = StringPrototypeToLowerCase ( mimeTypeObj ?. essence || '' ) ;
57+ const charset = StringPrototypeToLowerCase ( mimeTypeObj ?. params . get ( 'charset' ) || '' ) ;
6558
6659 return {
6760 __proto__ : null ,
Original file line number Diff line number Diff line change @@ -343,7 +343,8 @@ class MIMEType {
343343 #parameters;
344344 constructor ( string , noThrowSymbol = null ) {
345345 string = `${ string } ` ;
346- if ( noThrowSymbol != null && typeof noThrowSymbol != 'symbol' ) {
346+ // noThrowSymbol can be null or kNoThrow, but not any other value
347+ if ( noThrowSymbol != null && noThrowSymbol !== kNoThrow ) {
347348 throw new ERR_ILLEGAL_CONSTRUCTOR ( ) ;
348349 }
349350 const data = parseTypeAndSubtype ( string , noThrowSymbol ) ;
You can’t perform that action at this time.
0 commit comments