diff --git a/lib/serializer.js b/lib/serializer.js index df81960e..d92a4e32 100644 --- a/lib/serializer.js +++ b/lib/serializer.js @@ -1,8 +1,5 @@ 'use strict' -// eslint-disable-next-line -const STR_ESCAPE = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/ - module.exports = class Serializer { constructor (options) { switch (options && options.rounding) { @@ -117,7 +114,7 @@ module.exports = class Serializer { } } return (last === -1 && ('"' + str + '"')) || ('"' + result + str.slice(last) + '"') - } else if (len < 5000 && STR_ESCAPE.test(str) === false) { + } else if (len < 5000 && str.isWellFormed()) { // Only use the regular expression for shorter input. The overhead is otherwise too much. return '"' + str + '"' } else {