computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
722 B
27 lines
722 B
1 year ago
|
export function getUrlParams() {
|
||
|
const params = new URLSearchParams(window.location.search);
|
||
|
const paramsObj: Record<string, any> = {};
|
||
|
for (const [key, value] of params.entries()) {
|
||
|
paramsObj[key] = value;
|
||
|
}
|
||
|
|
||
|
return paramsObj;
|
||
|
}
|
||
|
|
||
|
export function deleteUrlParam(key: string) {
|
||
|
const url = new URL(window.location.href);
|
||
|
url.searchParams.delete(key);
|
||
|
window.history.pushState(null, '', url.toString());
|
||
|
}
|
||
|
|
||
|
export function setUrlParams(params: Record<string, string>) {
|
||
|
const url = new URL(window.location.href);
|
||
|
|
||
|
for (const [key, value] of Object.entries(params)) {
|
||
|
url.searchParams.delete(key);
|
||
|
url.searchParams.set(key, value);
|
||
|
}
|
||
|
|
||
|
window.history.pushState(null, '', url.toString());
|
||
|
}
|