Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit d574718

Browse files
greenkeeper[bot]honzajavorek
authored andcommitted
fix(package): update media-typer to version 1.0.2
Close #136
1 parent 0a39d93 commit d574718

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

lib/mixins/validatable-http-message.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const jph = require('json-parse-helpfulerror');
22
const mediaTyper = require('media-typer');
3+
const contentTypeModule = require('content-type');
34
const isset = require('../utils/isset');
45
const validators = require('../validators');
56

@@ -428,13 +429,16 @@ but body is not a parseable JSON:\n${error.message}\
428429
if (!contentType) {
429430
return false;
430431
}
431-
432-
const parsed = mediaTyper.parse(`${contentType}`);
433-
const isJson =
434-
(parsed.type === 'application' && parsed.subtype === 'json') ||
435-
parsed.suffix === 'json';
436-
437-
return isJson;
432+
try {
433+
const { type } = contentTypeModule.parse(`${contentType}`);
434+
const parsed = mediaTyper.parse(type);
435+
return (
436+
(parsed.type === 'application' && parsed.subtype === 'json')
437+
|| parsed.suffix === 'json'
438+
);
439+
} catch (e) {
440+
return false;
441+
}
438442
}
439443
}
440444

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626
"caseless": "0.12.0",
2727
"clone": "2.1.2",
2828
"commander": "2.20.0",
29+
"content-type": "1.0.4",
2930
"curl-trace-parser": "0.0.10",
3031
"deep-equal": "1.0.1",
3132
"googlediff": "0.1.0",
3233
"http-string-parser": "0.0.6",
3334
"json-parse-helpfulerror": "1.0.3",
3435
"json-pointer": "0.6.0",
35-
"media-typer": "0.3.0",
36+
"media-typer": "1.0.2",
3637
"tv4": "1.3.0"
3738
},
3839
"devDependencies": {

0 commit comments

Comments
 (0)