File "use-query-params.js"
Full Path: /home/warrior1/public_html/languages/wp-content/plugins/elementor/app/assets/js/hooks/use-query-params.js
File size: 562 bytes
MIME-type: text/plain
Charset: utf-8
export default function useQueryParams() {
const urlSearchParams = new URLSearchParams( window.location.search ),
urlParams = Object.fromEntries( urlSearchParams.entries() ),
hashValue = location.hash.match( /\?(.+)/ )?.[ 1 ],
hashParams = {};
if ( hashValue ) {
hashValue.split( '&' ).forEach( ( pair ) => {
const [ key, value ] = pair.split( '=' );
hashParams[ key ] = value;
} );
}
// Merging the URL params with the hash params.
const queryParams = {
...urlParams,
...hashParams,
};
return {
getAll: () => queryParams,
};
}