Skip to content

Setting up setCookie and getCookie modules - #3

Open
vickymeenakshisundaram wants to merge 1 commit into
adobecom:mainfrom
vickymeenakshisundaram:main
Open

Setting up setCookie and getCookie modules#3
vickymeenakshisundaram wants to merge 1 commit into
adobecom:mainfrom
vickymeenakshisundaram:main

Conversation

@vickymeenakshisundaram

Copy link
Copy Markdown

Setup setCookie and getCookie modules
Resolves MWPW-175571

if (httpOnly) cookieString += `; HttpOnly`;
if (sameSite) cookieString += `; SameSite=${sameSite}`;

const key = Object.keys(headers).find(k => k.toLowerCase() === 'set-cookie') || 'set-cookie';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');

@sharmrj sharmrj Jun 30, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, instead of iterating through the headers, couldn't we do const cookies = headers['Cookie'] ?? headers ['cookie'];

Comment on lines +73 to +75
const cookieString = headers[cookieKey].join('; ');
const cookieParts = cookieString.split(';').map(c => c.trim());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why join only to immediately split again?

@adobecom-git-stale-pr-bot adobecom-git-stale-pr-bot Bot added stale No recent activity autoclose-pending Will be auto-closed soon labels Sep 3, 2026
@adobecom-git-stale-pr-bot

Copy link
Copy Markdown

No activity in 7 days. Will be labeled stale at 14 days. Auto-close is disabled this run. Add stale-ignore to exempt.

No activity in 14 days, labeled stale (removed automatically on new activity). Auto-close is disabled this run. Add stale-ignore to exempt.

No activity in 21 days, labeled autoclose-pending (removed automatically on new activity). Would normally close in 7 days, but auto-close is disabled this run. Add autoclose-ignore to exempt.

No activity in 28 days. Would normally close now, but auto-close is disabled this run. Add autoclose-ignore to exempt.


Rundeck job Git Stale PR Check (git-stale-pr-bot), execution 2739336, project global, run by casalino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoclose-pending Will be auto-closed soon stale No recent activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants