mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
17 lines
468 B
TypeScript
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;
|
|
};
|