File tree Expand file tree Collapse file tree 4 files changed +10
-9
lines changed Expand file tree Collapse file tree 4 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ export type StringifyOptions = {
412
412
readonly skipEmptyString ?: boolean ;
413
413
} ;
414
414
415
- export type Stringifiable = string | boolean | number | null | undefined ; // eslint-disable-line @typescript-eslint/ban-types
415
+ export type Stringifiable = string | boolean | number | bigint | null | undefined ; // eslint-disable-line @typescript-eslint/ban-types
416
416
417
417
export type StringifiableRecord = Record <
418
418
string ,
Original file line number Diff line number Diff line change @@ -385,13 +385,7 @@ export function parse(query, options) {
385
385
// eslint-disable-next-line unicorn/no-array-reduce
386
386
return ( options . sort === true ? Object . keys ( returnValue ) . sort ( ) : Object . keys ( returnValue ) . sort ( options . sort ) ) . reduce ( ( result , key ) => {
387
387
const value = returnValue [ key ] ;
388
- if ( Boolean ( value ) && typeof value === 'object' && ! Array . isArray ( value ) ) {
389
- // Sort object keys, not values
390
- result [ key ] = keysSorter ( value ) ;
391
- } else {
392
- result [ key ] = value ;
393
- }
394
-
388
+ result [ key ] = Boolean ( value ) && typeof value === 'object' && ! Array . isArray ( value ) ? keysSorter ( value ) : value ;
395
389
return result ;
396
390
} , Object . create ( null ) ) ;
397
391
}
Original file line number Diff line number Diff line change 55
55
"deep-equal" : " ^2.1.0" ,
56
56
"fast-check" : " ^3.4.0" ,
57
57
"tsd" : " ^0.25.0" ,
58
- "xo" : " ^0.53.1 "
58
+ "xo" : " ^0.54.2 "
59
59
},
60
60
"tsd" : {
61
61
"compilerOptions" : {
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ test('different types', t => {
14
14
t . is ( queryString . stringify ( 0 ) , '' ) ;
15
15
} ) ;
16
16
17
+ test ( 'primitive types' , t => {
18
+ t . is ( queryString . stringify ( { a : 'string' } ) , 'a=string' ) ;
19
+ t . is ( queryString . stringify ( { a : true , b : false } ) , 'a=true&b=false' ) ;
20
+ t . is ( queryString . stringify ( { a : 0 , b : 1n } ) , 'a=0&b=1' ) ;
21
+ t . is ( queryString . stringify ( { a : null , b : undefined } ) , 'a' ) ;
22
+ } ) ;
23
+
17
24
test ( 'URI encode' , t => {
18
25
t . is ( queryString . stringify ( { 'foo bar' : 'baz faz' } ) , 'foo%20bar=baz%20faz' ) ;
19
26
t . is ( queryString . stringify ( { 'foo bar' : 'baz\'faz' } ) , 'foo%20bar=baz%27faz' ) ;
You can’t perform that action at this time.
0 commit comments