@@ -6,6 +6,8 @@ const filterObject = require('filter-obj');
66
77const isNullOrUndefined = value => value === null || value === undefined ;
88
9+ const encodeFragmentIdentifier = Symbol ( 'encodeFragmentIdentifier' ) ;
10+
911function encoderForArrayFormat ( options ) {
1012 switch ( options . arrayFormat ) {
1113 case 'index' :
@@ -402,7 +404,8 @@ exports.parseUrl = (url, options) => {
402404exports . stringifyUrl = ( object , options ) => {
403405 options = Object . assign ( {
404406 encode : true ,
405- strict : true
407+ strict : true ,
408+ [ encodeFragmentIdentifier ] : true
406409 } , options ) ;
407410
408411 const url = removeHash ( object . url ) . split ( '?' ) [ 0 ] || '' ;
@@ -417,15 +420,16 @@ exports.stringifyUrl = (object, options) => {
417420
418421 let hash = getHash ( object . url ) ;
419422 if ( object . fragmentIdentifier ) {
420- hash = `#${ encode ( object . fragmentIdentifier , options ) } ` ;
423+ hash = `#${ options [ encodeFragmentIdentifier ] ? encode ( object . fragmentIdentifier , options ) : object . fragmentIdentifier } ` ;
421424 }
422425
423426 return `${ url } ${ queryString } ${ hash } ` ;
424427} ;
425428
426429exports . pick = ( input , filter , options ) => {
427430 options = Object . assign ( {
428- parseFragmentIdentifier : true
431+ parseFragmentIdentifier : true ,
432+ [ encodeFragmentIdentifier ] : false
429433 } , options ) ;
430434
431435 const { url, query, fragmentIdentifier} = exports . parseUrl ( input , options ) ;
0 commit comments