@@ -1014,7 +1014,8 @@ Request.prototype._end = function() {
10141014
10151015 const max = this . _maxRedirects ;
10161016 const mime = utils . type ( res . headers [ 'content-type' ] || '' ) || 'text/plain' ;
1017- const type = mime . split ( '/' ) [ 0 ] ;
1017+ let type = mime . split ( '/' ) [ 0 ] ;
1018+ if ( type ) type = type . toLowerCase ( ) . trim ( ) ;
10181019 const multipart = type === 'multipart' ;
10191020 const redirect = isRedirect ( res . statusCode ) ;
10201021 const responseType = this . _responseType ;
@@ -1331,14 +1332,17 @@ methods.forEach(method => {
13311332
13321333function isText ( mime ) {
13331334 const parts = mime . split ( '/' ) ;
1334- const type = parts [ 0 ] ;
1335- const subtype = parts [ 1 ] ;
1335+ let type = parts [ 0 ] ;
1336+ if ( type ) type = type . toLowerCase ( ) . trim ( ) ;
1337+ let subtype = parts [ 1 ] ;
1338+ if ( subtype ) subtype = subtype . toLowerCase ( ) . trim ( ) ;
13361339
13371340 return type === 'text' || subtype === 'x-www-form-urlencoded' ;
13381341}
13391342
13401343function isImageOrVideo ( mime ) {
1341- const type = mime . split ( '/' ) [ 0 ] ;
1344+ let type = mime . split ( '/' ) [ 0 ] ;
1345+ if ( type ) type = type . toLowerCase ( ) . trim ( ) ;
13421346
13431347 return type === 'image' || type === 'video' ;
13441348}
@@ -1354,7 +1358,7 @@ function isImageOrVideo(mime) {
13541358function isJSON ( mime ) {
13551359 // should match /json or +json
13561360 // but not /json-seq
1357- return / [ / + ] j s o n ( $ | [ ^ - \w ] ) / . test ( mime ) ;
1361+ return / [ / + ] j s o n ( $ | [ ^ - \w ] ) / i . test ( mime ) ;
13581362}
13591363
13601364/**
0 commit comments