import 'url-search-params-polyfill' ; export function pathWithParams ( path , additionalParams ? , whitelistParams ? , search = window . location . search ) { const params = paramsToRecord ( search ) ; if ( additionalParams ) { Object . assign ( params , additionalParams ) ; } if ( whitelistParams ) { Object . keys ( params ) . forEach ( key => { if ( ! whitelistParams . includes ( key ) ) { delete params [ key ] ; } } ) ; } const queryString = new URLSearchParams ( params ) . toString ( ) ; return `${ path }${ queryString ? `?${ queryString }` : '' }` ; } export function paramsToRecord ( params ) { const records = { } ; new URLSearchParams ( params ) . forEach ( ( value , key ) => { records [ key ] = value ; } ) ; return records ; } export function getURLParameter ( parameterName , search = window . location . search ) { return new URLSearchParams ( search ) . get ( parameterName ) || '' ; } export function hasURLParameter ( parameterName , search = window . location . search ) { return ! ! new URLSearchParams ( search ) . has ( parameterName ) ; }