/**
 * Get All Params from Url
 *
 * @param queryOptions
 * @returns {{}}
 */
function getUrlSearchParams(queryOptions = null) {
    let hashes = [];

    if(queryOptions) {
        hashes = queryOptions.map(query => {
            return query.replace('?', '');
        });
    } else {
        hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    }

    const query = {};
    hashes.forEach(hash => {
        hash = hash.split('=');
        if(hash[1] !== 'search') {

            if(hash[0] === 'q') {
                const params = new URLSearchParams(window.location.search);
                query[hash[0]] = params.get('q');
            } else {
                query[hash[0]] = hash[1];
            }
        }
    });

    return query;
}

export {
    getUrlSearchParams
}