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 = {
412412 readonly skipEmptyString ?: boolean ;
413413} ;
414414
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
416416
417417export type StringifiableRecord = Record <
418418string ,
Original file line number Diff line number Diff line change @@ -385,13 +385,7 @@ export function parse(query, options) {
385385 // eslint-disable-next-line unicorn/no-array-reduce
386386 return ( options . sort === true ? Object . keys ( returnValue ) . sort ( ) : Object . keys ( returnValue ) . sort ( options . sort ) ) . reduce ( ( result , key ) => {
387387 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 ;
395389 return result ;
396390 } , Object . create ( null ) ) ;
397391}
Original file line number Diff line number Diff line change 5555 "deep-equal" : " ^2.1.0" ,
5656 "fast-check" : " ^3.4.0" ,
5757 "tsd" : " ^0.25.0" ,
58- "xo" : " ^0.53.1 "
58+ "xo" : " ^0.54.2 "
5959 },
6060 "tsd" : {
6161 "compilerOptions" : {
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ test('different types', t => {
1414 t . is ( queryString . stringify ( 0 ) , '' ) ;
1515} ) ;
1616
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+
1724test ( 'URI encode' , t => {
1825 t . is ( queryString . stringify ( { 'foo bar' : 'baz faz' } ) , 'foo%20bar=baz%20faz' ) ;
1926 t . is ( queryString . stringify ( { 'foo bar' : 'baz\'faz' } ) , 'foo%20bar=baz%27faz' ) ;
You can’t perform that action at this time.
0 commit comments