1
0
Fork 0
mirror of https://github.com/classchartsapi/classcharts-api-js.git synced 2026-05-14 19:59:37 +00:00

feat: parse cookies properly (#15)

This commit is contained in:
James Cook 2022-08-03 16:53:46 +01:00 committed by GitHub
parent 70bf79e019
commit 64909d82b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 23 deletions

11
src/utils.ts Normal file
View file

@ -0,0 +1,11 @@
export function parseCookies(input: string) {
const output: Record<string, unknown> = {};
const cookies = input.split(",");
for (const cookie of cookies) {
const cookieSplit = cookie.split(";")[0].split("=");
output[decodeURIComponent(cookieSplit[0])] = decodeURIComponent(
cookieSplit[1]
);
}
return output;
}