File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,10 @@ export const defaultSerialize = (data: any): string => {
28
28
// eslint-disable-next-line guard-for-in
29
29
for ( const k in data ) {
30
30
const ignore = typeof data [ k ] === 'function' || ( ! array && data [ k ] === undefined ) ;
31
- if ( ! Object . prototype . hasOwnProperty . call ( data , k ) || ignore ) {
32
- continue ;
33
- }
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
32
+ if ( ! Object . hasOwn ( data , k ) || ignore ) {
33
+ continue ;
34
+ }
34
35
35
36
if ( ! first ) {
36
37
s += ',' ;
Original file line number Diff line number Diff line change @@ -71,6 +71,15 @@ test.it('defaultSerialize detects base64 on string', t => {
71
71
t . expect ( result . encoded . toString ( ) ) . toBe ( 'hello world' ) ;
72
72
} ) ;
73
73
74
+ test . it ( 'defaultSerialize accepts objects created with null' , t => {
75
+ const json = Object . create ( null ) ;
76
+ json . someKey = 'value' ;
77
+
78
+ const result = defaultSerialize < { someKey : string } > ( json ) ;
79
+
80
+ t . expect ( result ) . toStrictEqual ( '{"someKey":"value"}' ) ;
81
+ } ) ;
82
+
74
83
test . it ( 'removes the first colon from strings not prefixed by base64' , t => {
75
84
const json = JSON . stringify ( {
76
85
simple : ':hello' ,
You can’t perform that action at this time.
0 commit comments