Skip to content

Commit bb328ea

Browse files
committed
escape U+0000
1 parent 081f528 commit bb328ea

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const escaped: Record<string, string> = {
1010
'\n': '\\n',
1111
'\r': '\\r',
1212
'\t': '\\t',
13+
'\0': '\\0',
1314
'\u2028': '\\u2028',
1415
'\u2029': '\\u2029'
1516
};

test/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('devalue', () => {
4444
test('two high surrogates', "a\uD800\uD800b", '"a\\uD800\\uD800b"');
4545
test('surrogate pair', '𝌆', JSON.stringify('𝌆'));
4646
test('surrogate pair in wrong order', 'a\uDC00\uD800b', '"a\\uDC00\\uD800b"');
47-
test('nul', '\0', '"\0"');
47+
test('nul', '\0', '"\\0"');
4848
test('backslash', '\\', JSON.stringify('\\'));
4949
});
5050

0 commit comments

Comments
 (0)