diff --git a/lib/serializer.js b/lib/serializer.js index 1e6a8eaf..387e8927 100644 --- a/lib/serializer.js +++ b/lib/serializer.js @@ -101,7 +101,8 @@ module.exports = class Serializer { asString (str) { if (str.length < 42) { return this.asStringSmall(str) - } else if (STR_ESCAPE.test(str) === false) { + } else if (str.length < 5000 && STR_ESCAPE.test(str) === false) { + // Only use the regular expression for shorter input. The overhead is otherwise too much. return '"' + str + '"' } else { return JSON.stringify(str)