mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
15 lines
408 B
TypeScript
15 lines
408 B
TypeScript
export default class CookieHelper {
|
|
public static parseCookieString(string: string): { [key: string]: string } {
|
|
const values = string
|
|
.split(';')
|
|
.map(v => v.split('='))
|
|
.reduce((acc, value) => {
|
|
const [key, ...rest] = value;
|
|
acc[decodeURIComponent(key.trim())] = decodeURIComponent(rest.join('=').trim());
|
|
return acc;
|
|
}, {});
|
|
|
|
return values;
|
|
}
|
|
}
|