File tree 3 files changed +11
-3
lines changed
3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## v2.3.1
4
+
5
+ - Fix ` invalid regexp group ` error in browsers or environments that do not support the negative lookbehind regular expression assertion.
6
+
3
7
## v2.3.0
4
8
5
9
- Accept the ` Error ` constructor as ` circularValue ` option to throw on circular references as the regular JSON.stringify would:
Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ exports.configure = configure
18
18
module . exports = stringify
19
19
20
20
// eslint-disable-next-line
21
- const strEscapeSequencesRegExp = / [ \u0000 - \u001f \u0022 \u005c \ud800 - \udfff ] | [ \ud800 - \udbff ] (? ! [ \udc00 - \udfff ] ) | (?< ! [ \ud800 - \udbff ] ) [ \udc00 - \udfff ] /
21
+ const strEscapeSequencesRegExp = / [ \u0000 - \u001f \u0022 \u005c \ud800 - \udfff ] | [ \ud800 - \udbff ] (? ! [ \udc00 - \udfff ] ) | (?: [ ^ \ud800 - \udbff ] | ^ ) [ \udc00 - \udfff ] /
22
22
// eslint-disable-next-line
23
- const strEscapeSequencesReplacer = / [ \u0000 - \u001f \u0022 \u005c \ud800 - \udfff ] | [ \ud800 - \udbff ] (? ! [ \udc00 - \udfff ] ) | (?< ! [ \ud800 - \udbff ] ) [ \udc00 - \udfff ] / g
23
+ const strEscapeSequencesReplacer = / [ \u0000 - \u001f \u0022 \u005c \ud800 - \udfff ] | [ \ud800 - \udbff ] (? ! [ \udc00 - \udfff ] ) | (?: [ ^ \ud800 - \udbff ] | ^ ) [ \udc00 - \udfff ] / g
24
24
25
25
// Escaped special characters. Use empty strings to fill up unused entries.
26
26
const meta = [
@@ -40,6 +40,10 @@ const meta = [
40
40
]
41
41
42
42
function escapeFn ( str ) {
43
+ if ( str . length === 2 ) {
44
+ const charCode = str . charCodeAt ( 1 )
45
+ return `${ str [ 0 ] } \\u${ charCode . toString ( 16 ) } `
46
+ }
43
47
const charCode = str . charCodeAt ( 0 )
44
48
return meta . length > charCode
45
49
? meta [ charCode ]
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " safe-stable-stringify" ,
3
- "version" : " 2.3.0 " ,
3
+ "version" : " 2.3.1 " ,
4
4
"description" : " Deterministic and safely JSON.stringify to quickly serialize JavaScript objects" ,
5
5
"exports" : {
6
6
"require" : " ./index.js" ,
You can’t perform that action at this time.
0 commit comments