set cookies properly

This commit is contained in:
Harsh Gupta 2024-08-15 22:48:52 +05:30
parent 49a90ee7d4
commit 66183d8216

View File

@ -879,10 +879,13 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
const cookies = req.headers['x-set-cookie'] ?
(Array.isArray(req.headers['x-set-cookie']) ? req.headers['x-set-cookie'] : [req.headers['x-set-cookie']])
.map(cookie => {
const [name, value] = cookie.split('=');
.flatMap(cookieString =>
cookieString.split(';').map(cookie => {
const [name, ...valueParts] = cookie.trim().split('=');
const value = valueParts.join('=');
return { name, value, url: urlToCrawl.toString() };
})
)
: [];
console.log('Cookies:', cookies);