Add method to create segments from url parameters

This commit is contained in:
Ajay
2022-01-14 19:21:09 -05:00
parent cf9e016581
commit 31014b78ac
2 changed files with 40 additions and 11 deletions

View File

@@ -40,4 +40,19 @@ function findValidElementFromGenerator<T>(objects: T[] | NodeListOf<HTMLElement>
}
return null;
}
export function getHashParams(): Record<string, unknown> {
const windowHash = window.location.hash.substr(1);
if (windowHash) {
const params: Record<string, unknown> = windowHash.split('&').reduce((acc, param) => {
const [key, value] = param.split('=');
acc[key] = value;
return acc;
}, {});
return params;
}
return {};
}