This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
const jph = require ( 'json-parse-helpfulerror' ) ;
2
2
const mediaTyper = require ( 'media-typer' ) ;
3
- const contentTypeModule = require ( 'content-type' ) ;
3
+ const contentType = require ( 'content-type' ) ;
4
4
const isset = require ( '../utils/isset' ) ;
5
5
const validators = require ( '../validators' ) ;
6
6
@@ -425,18 +425,21 @@ but body is not a parseable JSON:\n${error.message}\
425
425
) ;
426
426
}
427
427
428
- isJsonContentType ( contentType ) {
429
- if ( ! contentType ) {
428
+ isJsonContentType ( contentTypeValue ) {
429
+ if ( ! contentTypeValue ) {
430
430
return false ;
431
431
}
432
432
try {
433
- const { type } = contentTypeModule . parse ( `${ contentType } ` ) ;
433
+ const { type } = contentType . parse ( `${ contentTypeValue } ` ) ;
434
434
const parsed = mediaTyper . parse ( type ) ;
435
435
return (
436
436
( parsed . type === 'application' && parsed . subtype === 'json' )
437
437
|| parsed . suffix === 'json'
438
438
) ;
439
439
} catch ( e ) {
440
+ // The Content-Type value is basically a user input, it can be any
441
+ // kind of rubbish, and it is neither this function's nor Gavel's problem
442
+ // if it's invalid
440
443
return false ;
441
444
}
442
445
}
You can’t perform that action at this time.
0 commit comments