Honestly way too much went into this single commit. I am so sorry future me

This commit is contained in:
Emma
2023-06-09 00:54:00 -06:00
parent cd3f653f3f
commit 42c0004150
67 changed files with 4617 additions and 92 deletions

View File

@@ -0,0 +1,20 @@
export class QueryParams {
private params = new Map<string, string>()
constructor(options?: {clean: boolean}) {
if (!options?.clean) {
const {search} = location;
for (const [key, value] of search.replace('?', '').split('&').map(e => e.split('='))) {
this.params.set(key, value);
}
}
}
get = this.params.get
set = this.params.set
delete = this.params.delete
clear = this.params.clear
apply() {
location.search = '?' + encodeURIComponent(Array.from(this.params.entries()).map(e => e.join('=')).join('&'))
}
}