Skip to content

Commit ed75e11

Browse files
committed
Revert "refactor: use built-in wellformed operation (#774)"
This reverts commit 7f48cb6.
1 parent 71c0174 commit ed75e11

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/serializer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict'
22

3+
// eslint-disable-next-line
4+
const STR_ESCAPE = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/
5+
36
module.exports = class Serializer {
47
constructor (options) {
58
switch (options && options.rounding) {
@@ -116,7 +119,7 @@ module.exports = class Serializer {
116119
}
117120
}
118121
return (last === -1 && ('"' + str + '"')) || ('"' + result + str.slice(last) + '"')
119-
} else if (len < 5000 && str.isWellFormed()) {
122+
} else if (len < 5000 && STR_ESCAPE.test(str) === false) {
120123
// Only use the regular expression for shorter input. The overhead is otherwise too much.
121124
return '"' + str + '"'
122125
} else {

0 commit comments

Comments
 (0)