Skip to content

Commit 681f8b8

Browse files
committed
Strictly validate that the jsonString argument is a string
Fixes #43
1 parent e60ad00 commit 681f8b8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const isEscaped = (jsonString, quotePosition) => {
1717
};
1818

1919
module.exports = (jsonString, options = {}) => {
20+
if (typeof jsonString !== 'string') {
21+
throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
22+
}
23+
2024
const strip = options.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
2125

2226
let insideString = false;

0 commit comments

Comments
 (0)