Skip to content

Commit

Permalink
🔀 merge pull request #278 from tonightpass/younesbessa/parse-cookie-s…
Browse files Browse the repository at this point in the history
…tring

🐛 fix parsecookiestring function
  • Loading branch information
AntoineKM authored Jul 17, 2023
2 parents 78d17c0 + cbfdd27 commit b41ec22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fresh-plums-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tonightpass/kitchen": patch
---

Fix parseCookieString function
7 changes: 6 additions & 1 deletion packages/kitchen/src/utils/parseCookieString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ const parseCookieString = (cookieString: string) => {
const cookieObject = cookieArray.reduce((acc, cookie) => {
const [key, encodedValue] = cookie.split("=");
const value = decodeURIComponent(encodedValue);
const parsedValue = value !== "undefined" ? JSON.parse(value) : undefined;
const parsedValue =
value !== "undefined"
? value.includes(":")
? value
: JSON.parse(value)
: undefined;
return { ...acc, [key.trim()]: parsedValue };
}, {});
return cookieObject;
Expand Down

2 comments on commit b41ec22

@vercel
Copy link

@vercel vercel bot commented on b41ec22 Jul 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

kitchen-workshop – ./workshop

kitchen-workshop-git-master-tonightpass.vercel.app
kitchen-workshop.vercel.app
kitchen-workshop-tonightpass.vercel.app

@vercel
Copy link

@vercel vercel bot commented on b41ec22 Jul 17, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.