@@ -214,7 +214,7 @@ function parseValue(value, options) {
214
214
return value ;
215
215
}
216
216
217
- function parse ( input , options ) {
217
+ function parse ( query , options ) {
218
218
options = Object . assign ( {
219
219
decode : true ,
220
220
sort : true ,
@@ -231,17 +231,17 @@ function parse(input, options) {
231
231
// Create an object with no prototype
232
232
const ret = Object . create ( null ) ;
233
233
234
- if ( typeof input !== 'string' ) {
234
+ if ( typeof query !== 'string' ) {
235
235
return ret ;
236
236
}
237
237
238
- input = input . trim ( ) . replace ( / ^ [ ? # & ] / , '' ) ;
238
+ query = query . trim ( ) . replace ( / ^ [ ? # & ] / , '' ) ;
239
239
240
- if ( ! input ) {
240
+ if ( ! query ) {
241
241
return ret ;
242
242
}
243
243
244
- for ( const param of input . split ( '&' ) ) {
244
+ for ( const param of query . split ( '&' ) ) {
245
245
let [ key , value ] = splitOnFirst ( options . decode ? param . replace ( / \+ / g, ' ' ) : param , '=' ) ;
246
246
247
247
// Missing `=` should be `null`:
@@ -337,41 +337,41 @@ exports.stringify = (object, options) => {
337
337
} ) . filter ( x => x . length > 0 ) . join ( '&' ) ;
338
338
} ;
339
339
340
- exports . parseUrl = ( input , options ) => {
340
+ exports . parseUrl = ( url , options ) => {
341
341
options = Object . assign ( {
342
342
decode : true
343
343
} , options ) ;
344
344
345
- const [ url , hash ] = splitOnFirst ( input , '#' ) ;
345
+ const [ url_ , hash ] = splitOnFirst ( url , '#' ) ;
346
346
347
347
return Object . assign (
348
348
{
349
- url : url . split ( '?' ) [ 0 ] || '' ,
350
- query : parse ( extract ( input ) , options )
349
+ url : url_ . split ( '?' ) [ 0 ] || '' ,
350
+ query : parse ( extract ( url ) , options )
351
351
} ,
352
352
options && options . parseFragmentIdentifier && hash ? { fragmentIdentifier : decode ( hash , options ) } : { }
353
353
) ;
354
354
} ;
355
355
356
- exports . stringifyUrl = ( input , options ) => {
356
+ exports . stringifyUrl = ( object , options ) => {
357
357
options = Object . assign ( {
358
358
encode : true ,
359
359
strict : true
360
360
} , options ) ;
361
361
362
- const url = removeHash ( input . url ) . split ( '?' ) [ 0 ] || '' ;
363
- const queryFromUrl = exports . extract ( input . url ) ;
362
+ const url = removeHash ( object . url ) . split ( '?' ) [ 0 ] || '' ;
363
+ const queryFromUrl = exports . extract ( object . url ) ;
364
364
const parsedQueryFromUrl = exports . parse ( queryFromUrl , { sort : false } ) ;
365
365
366
- const query = Object . assign ( parsedQueryFromUrl , input . query ) ;
366
+ const query = Object . assign ( parsedQueryFromUrl , object . query ) ;
367
367
let queryString = exports . stringify ( query , options ) ;
368
368
if ( queryString ) {
369
369
queryString = `?${ queryString } ` ;
370
370
}
371
371
372
- let hash = getHash ( input . url ) ;
373
- if ( input . fragmentIdentifier ) {
374
- hash = `#${ encode ( input . fragmentIdentifier , options ) } ` ;
372
+ let hash = getHash ( object . url ) ;
373
+ if ( object . fragmentIdentifier ) {
374
+ hash = `#${ encode ( object . fragmentIdentifier , options ) } ` ;
375
375
}
376
376
377
377
return `${ url } ${ queryString } ${ hash } ` ;
0 commit comments