export const query2obj = ( str ) => { const res = { } ; str . replace ( /([^=?#&]*)=([^?#&]*)/g , function ( _ , $1 , $2 ) { res [ decodeURIComponent ( $1 ) ] = decodeURIComponent ( $2 ) ; return '' ; } ) ; return res ; } ; export const obj2query = ( obj ) => { return Object . keys ( obj ) . map ( function ( key ) { return encodeURIComponent ( key ) + '=' + encodeURIComponent ( obj [ key ] ) ; } ) . join ( '&' ) ; } ;