@@ -5,7 +5,7 @@ import {includeKeys} from 'filter-obj';
5
5
const isNullOrUndefined = value => value === null || value === undefined ;
6
6
7
7
// eslint-disable-next-line unicorn/prefer-code-point
8
- const strictUriEncode = string => encodeURIComponent ( string ) . replace ( / [ ! ' ( ) * ] / g, x => `%${ x . charCodeAt ( 0 ) . toString ( 16 ) . toUpperCase ( ) } ` ) ;
8
+ const strictUriEncode = string => encodeURIComponent ( string ) . replaceAll ( / [ ! ' ( ) * ] / g, x => `%${ x . charCodeAt ( 0 ) . toString ( 16 ) . toUpperCase ( ) } ` ) ;
9
9
10
10
const encodeFragmentIdentifier = Symbol ( 'encodeFragmentIdentifier' ) ;
11
11
@@ -87,7 +87,7 @@ function encoderForArrayFormat(options) {
87
87
case 'comma' :
88
88
case 'separator' :
89
89
case 'bracket-separator' : {
90
- const keyValueSep = options . arrayFormat === 'bracket-separator'
90
+ const keyValueSeparator = options . arrayFormat === 'bracket-separator'
91
91
? '[]='
92
92
: '=' ;
93
93
@@ -104,7 +104,7 @@ function encoderForArrayFormat(options) {
104
104
value = value === null ? '' : value ;
105
105
106
106
if ( result . length === 0 ) {
107
- return [ [ encode ( key , options ) , keyValueSep , encode ( value , options ) ] . join ( '' ) ] ;
107
+ return [ [ encode ( key , options ) , keyValueSeparator , encode ( value , options ) ] . join ( '' ) ] ;
108
108
}
109
109
110
110
return [ [ result , encode ( value , options ) ] . join ( options . arrayFormatSeparator ) ] ;
@@ -353,7 +353,7 @@ export function parse(query, options) {
353
353
continue ;
354
354
}
355
355
356
- const parameter_ = options . decode ? parameter . replace ( / \+ / g , ' ' ) : parameter ;
356
+ const parameter_ = options . decode ? parameter . replaceAll ( '+' , ' ' ) : parameter ;
357
357
358
358
let [ key , value ] = splitOnFirst ( parameter_ , '=' ) ;
359
359
@@ -395,10 +395,13 @@ export function stringify(object, options) {
395
395
return '' ;
396
396
}
397
397
398
- options = { encode : true ,
398
+ options = {
399
+ encode : true ,
399
400
strict : true ,
400
401
arrayFormat : 'none' ,
401
- arrayFormatSeparator : ',' , ...options } ;
402
+ arrayFormatSeparator : ',' ,
403
+ ...options ,
404
+ } ;
402
405
403
406
validateArrayFormatSeparator ( options . arrayFormatSeparator ) ;
404
407
@@ -484,9 +487,7 @@ export function stringifyUrl(object, options) {
484
487
} ;
485
488
486
489
let queryString = stringify ( query , options ) ;
487
- if ( queryString ) {
488
- queryString = `?${ queryString } ` ;
489
- }
490
+ queryString &&= `?${ queryString } ` ;
490
491
491
492
let hash = getHash ( object . url ) ;
492
493
if ( typeof object . fragmentIdentifier === 'string' ) {
0 commit comments