plane/app/lib/cookie.ts
sriram veeraghanta 1538b99a28 removing trubo
2023-04-21 19:30:36 -04:00

17 lines
468 B
TypeScript

export const convertCookieStringToObject = (cookieHeader: string | undefined) => {
const list: any = {};
if (!cookieHeader) return list;
cookieHeader.split(`;`).forEach(function (cookie) {
// eslint-disable-next-line prefer-const
let [name, ...rest] = cookie.split(`=`);
name = name?.trim();
if (!name) return;
const value = rest.join(`=`).trim();
if (!value) return;
list[name] = decodeURIComponent(value);
});
return list;
};