diff --git a/HISTORY.md b/HISTORY.md index 716afc6d..94429c1a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +Unreleased +========================= +* refactor(json): simplify strict mode error string construction + 2.2.1 / 2025-11-24 ========================= diff --git a/lib/types/json.js b/lib/types/json.js index 058fcc62..23c73577 100644 --- a/lib/types/json.js +++ b/lib/types/json.js @@ -102,11 +102,7 @@ function createStrictSyntaxError (str, char) { var partial = '' if (index !== -1) { - partial = str.substring(0, index) + JSON_SYNTAX_CHAR - - for (var i = index + 1; i < str.length; i++) { - partial += JSON_SYNTAX_CHAR - } + partial = str.substring(0, index) + JSON_SYNTAX_CHAR.repeat(str.length - index) } try {