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

Commit 519965b

Browse files
committed
refactor: rename variables, add a comment
1 parent 793bce4 commit 519965b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/mixins/validatable-http-message.js

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

@@ -425,18 +425,21 @@ but body is not a parseable JSON:\n${error.message}\
425425
);
426426
}
427427

428-
isJsonContentType(contentType) {
429-
if (!contentType) {
428+
isJsonContentType(contentTypeValue) {
429+
if (!contentTypeValue) {
430430
return false;
431431
}
432432
try {
433-
const { type } = contentTypeModule.parse(`${contentType}`);
433+
const { type } = contentType.parse(`${contentTypeValue}`);
434434
const parsed = mediaTyper.parse(type);
435435
return (
436436
(parsed.type === 'application' && parsed.subtype === 'json')
437437
|| parsed.suffix === 'json'
438438
);
439439
} 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
440443
return false;
441444
}
442445
}

0 commit comments

Comments
 (0)