Javascript Reload page

Date: 2020-12-17
function getQueryParams(qs: string) {
    const params: { [key: string]: any } = {};
    qs = qs.split("+").join(" ");
    let tokens;
    const re = /[?&]?([^=]+)=([^&]*)/g;
    // eslint-disable-next-line no-cond-assign
    while (tokens = re.exec(qs)) {
        params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
    }
    return params;
}

function createQuery(data: any) {
    const c = encodeURIComponent;
    const cv = (v: any) => v && v.toISOString ? v.toISOString() : v;
    return "?" + Object.keys(data).map(k => `${c(k)}=${c(cv(data[k]))}`).join("&");
}

function getRefreshUrl(l: Location): string {
    const query = getQueryParams(l.search);
    query._ = String(Math.random()).slice(2);
    return l.origin + l.pathname + createQuery(query) + l.hash;
}

const url = getRefreshUrl(window.location);
console.log(url)
window.location.href = url;
43680cookie-checkJavascript Reload page