mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-10 16:15:01 -04:00
parent
08d977b8cd
commit
c5c4e5d026
14 changed files with 7042 additions and 8486 deletions
18
src/tools/har-sanitizer/lib/hash.ts
Normal file
18
src/tools/har-sanitizer/lib/hash.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
export type HashMap = Record<string, string[]>;
|
||||
|
||||
export function toHashString(obj: HashMap): string {
|
||||
const params = new URLSearchParams();
|
||||
Object.entries(obj).forEach(([key, stringArr]) => {
|
||||
stringArr.forEach((value) => {
|
||||
params.append(key, value);
|
||||
});
|
||||
});
|
||||
return `#${params.toString()}`;
|
||||
}
|
||||
|
||||
export function getHashMap(hash: string): HashMap {
|
||||
const existingParams = new URLSearchParams(hash.replace('#', ''));
|
||||
return Object.fromEntries(
|
||||
[...existingParams.keys()].map(key => [key, existingParams.getAll(key)]),
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue