20 lines
482 B
TypeScript
20 lines
482 B
TypeScript
export const getQueryParam = (paramName: string) => {
|
|
const search = window.location.search;
|
|
const params = new URLSearchParams(search);
|
|
return params.get(paramName);
|
|
};
|
|
|
|
export const parseQueryParams = () => {
|
|
if (typeof window === "undefined") {
|
|
return {};
|
|
}
|
|
const params = new URLSearchParams(window.location.search);
|
|
const result: Record<string, string> = {};
|
|
|
|
for (const [key, value] of params.entries()) {
|
|
result[key] = value;
|
|
}
|
|
|
|
return result;
|
|
};
|