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

Commit

Permalink
fix(package): update media-typer to version 1.0.2
Browse files Browse the repository at this point in the history
Close #136
  • Loading branch information
greenkeeper[bot] authored and honzajavorek committed May 3, 2019
1 parent 0a39d93 commit d574718
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
18 changes: 11 additions & 7 deletions lib/mixins/validatable-http-message.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const jph = require('json-parse-helpfulerror');
const mediaTyper = require('media-typer');
const contentTypeModule = require('content-type');
const isset = require('../utils/isset');
const validators = require('../validators');

Expand Down Expand Up @@ -428,13 +429,16 @@ but body is not a parseable JSON:\n${error.message}\
if (!contentType) {
return false;
}

const parsed = mediaTyper.parse(`${contentType}`);
const isJson =
(parsed.type === 'application' && parsed.subtype === 'json') ||
parsed.suffix === 'json';

return isJson;
try {
const { type } = contentTypeModule.parse(`${contentType}`);
const parsed = mediaTyper.parse(type);
return (
(parsed.type === 'application' && parsed.subtype === 'json')
|| parsed.suffix === 'json'
);
} catch (e) {
return false;
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
"caseless": "0.12.0",
"clone": "2.1.2",
"commander": "2.20.0",
"content-type": "1.0.4",
"curl-trace-parser": "0.0.10",
"deep-equal": "1.0.1",
"googlediff": "0.1.0",
"http-string-parser": "0.0.6",
"json-parse-helpfulerror": "1.0.3",
"json-pointer": "0.6.0",
"media-typer": "0.3.0",
"media-typer": "1.0.2",
"tv4": "1.3.0"
},
"devDependencies": {
Expand Down

0 comments on commit d574718

Please sign in to comment.