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

Commit bd91c12

Browse files
fix: always use "JSON.parse()" instead of "jju"
1 parent dc5d4be commit bd91c12

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

lib/units/validateBody.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function getBodyType(body, contentType, httpMessageOrigin) {
7272
// Use strict JSON parsing for actual body.
7373
// This prevents any kind of normalization of trailing commas
7474
// and other custom transformations applied by "jju".
75-
parseJson(body, httpMessageOrigin === 'actual');
75+
parseJson(body);
7676

7777
const bodyMediaType = parseContentType(
7878
hasJsonContentType ? contentType : 'application/json'

lib/utils/parseJson.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
const { parse } = require('jju/lib/parse');
2-
3-
const parseJson = (json, strict = false, revivew) => {
4-
try {
5-
// Strict parsing uses native JSON parsing and implies
6-
// a given JSON is valid according to the spec.
7-
//
8-
// Non-strict parsing uses "jju" enhanced parsing
9-
// that allows trailing commas and potential other transformations.
10-
const jsonParser = strict ? JSON.parse : parse;
11-
return jsonParser(json, revivew);
12-
} catch (error) {
13-
throw error;
14-
}
1+
const parseJson = (json, revivew) => {
2+
return JSON.parse(json, revivew);
153
};
164

175
module.exports = parseJson;

0 commit comments

Comments
 (0)