feat(new tool): HAR file sanitizer

Fix #811
This commit is contained in:
sharevb 2025-03-09 21:09:30 +01:00 committed by ShareVB
parent 08d977b8cd
commit c5c4e5d026
14 changed files with 7042 additions and 8486 deletions

View 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)]),
);
}