Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const parseCookieHeader = cookieHeader => {
const cookies =
cookieHeader instanceof Array
? cookieHeader.map(Cookie.parse)
: [Cookie.parse(cookieHeader)];
return cookies.reduce(
(acc, cookie) => ({ ...acc, [cookie.key]: cookie.value }),
{}
);
};
return Promise.all(cookies.map(x => {
const cookie = typeof x === 'string' ? toughCookie.parse(x).toJSON() : x;
return this.page.setCookie(Object.assign(cookie, {
name: cookie.name || cookie.key
}));
}));
}