@@ -5,7 +5,7 @@ import {includeKeys} from 'filter-obj';
55const isNullOrUndefined = value => value === null || value === undefined ;
66
77// 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 ( ) } ` ) ;
99
1010const encodeFragmentIdentifier = Symbol ( 'encodeFragmentIdentifier' ) ;
1111
@@ -87,7 +87,7 @@ function encoderForArrayFormat(options) {
8787 case 'comma' :
8888 case 'separator' :
8989 case 'bracket-separator' : {
90- const keyValueSep = options . arrayFormat === 'bracket-separator'
90+ const keyValueSeparator = options . arrayFormat === 'bracket-separator'
9191 ? '[]='
9292 : '=' ;
9393
@@ -104,7 +104,7 @@ function encoderForArrayFormat(options) {
104104 value = value === null ? '' : value ;
105105
106106 if ( result . length === 0 ) {
107- return [ [ encode ( key , options ) , keyValueSep , encode ( value , options ) ] . join ( '' ) ] ;
107+ return [ [ encode ( key , options ) , keyValueSeparator , encode ( value , options ) ] . join ( '' ) ] ;
108108 }
109109
110110 return [ [ result , encode ( value , options ) ] . join ( options . arrayFormatSeparator ) ] ;
@@ -353,7 +353,7 @@ export function parse(query, options) {
353353 continue ;
354354 }
355355
356- const parameter_ = options . decode ? parameter . replace ( / \+ / g , ' ' ) : parameter ;
356+ const parameter_ = options . decode ? parameter . replaceAll ( '+' , ' ' ) : parameter ;
357357
358358 let [ key , value ] = splitOnFirst ( parameter_ , '=' ) ;
359359
@@ -395,10 +395,13 @@ export function stringify(object, options) {
395395 return '' ;
396396 }
397397
398- options = { encode : true ,
398+ options = {
399+ encode : true ,
399400 strict : true ,
400401 arrayFormat : 'none' ,
401- arrayFormatSeparator : ',' , ...options } ;
402+ arrayFormatSeparator : ',' ,
403+ ...options ,
404+ } ;
402405
403406 validateArrayFormatSeparator ( options . arrayFormatSeparator ) ;
404407
@@ -484,9 +487,7 @@ export function stringifyUrl(object, options) {
484487 } ;
485488
486489 let queryString = stringify ( query , options ) ;
487- if ( queryString ) {
488- queryString = `?${ queryString } ` ;
489- }
490+ queryString &&= `?${ queryString } ` ;
490491
491492 let hash = getHash ( object . url ) ;
492493 if ( typeof object . fragmentIdentifier === 'string' ) {
0 commit comments