Setting up setCookie and getCookie modules - #3
Conversation
| if (httpOnly) cookieString += `; HttpOnly`; | ||
| if (sameSite) cookieString += `; SameSite=${sameSite}`; | ||
|
|
||
| const key = Object.keys(headers).find(k => k.toLowerCase() === 'set-cookie') || 'set-cookie'; |
There was a problem hiding this comment.
Is it necessary to to iterate all the headers every time? Why not do
const existing = headers['Set-Cookie'] ?? headers['set-cookie'];| } | ||
|
|
||
| export const getCookie = (headers: Headers) => (name: string): Cookie | undefined => { | ||
| const cookieKey = Object.keys(headers).find(k => k.toLowerCase() === 'cookie'); |
There was a problem hiding this comment.
Again, instead of iterating through the headers, couldn't we do const cookies = headers['Cookie'] ?? headers ['cookie'];
| const cookieString = headers[cookieKey].join('; '); | ||
| const cookieParts = cookieString.split(';').map(c => c.trim()); | ||
|
|
There was a problem hiding this comment.
Why join only to immediately split again?
|
No activity in 7 days. Will be labeled No activity in 14 days, labeled No activity in 21 days, labeled No activity in 28 days. Would normally close now, but auto-close is disabled this run. Add Rundeck job Git Stale PR Check (git-stale-pr-bot), execution 2739336, project global, run by casalino |
Setup setCookie and getCookie modules
Resolves MWPW-175571