Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing single cookie #31

Closed
danielroe opened this issue May 17, 2024 · 5 comments · Fixed by #35
Closed

parsing single cookie #31

danielroe opened this issue May 17, 2024 · 5 comments · Fixed by #35

Comments

@danielroe
Copy link
Member

danielroe commented May 17, 2024

original issue: nuxt/nuxt#27246

It might be worth considering an option or separate function to return/decode only a single cookie.

What do you think @pi0?

@pi0
Copy link
Member

pi0 commented May 17, 2024

This library is for parsing Cookie header (incoming) which is multi value. Not sure to understand are you proposing to support Set-Cookie possible values too?

@danielroe
Copy link
Member Author

Just like serialize serialises only a single cookie, we could optionally decode only a single value (that is, skip calling the decode function for the other ones).

Like the difference between getRequestHeaders and getRequestHeader.

@Eazash
Copy link

Eazash commented May 18, 2024

@danielroe As an alternate solution, what if the decode function had access to the cookie key? Something like decode?(value: string, key: string). That way existing behaviour can be retained while allowing upstream to handle filtering by key to decode only a single value.

@pi0
Copy link
Member

pi0 commented May 22, 2024

#35 is a little bit more verbose but also gives more flexibility.

@danielroe one thing i would suggest for Nuxt use btw if perf of not parsing everytime matters, we could cache the value of parses Cookie value (string) and only reparse when changed but i guess filter would work too.

I delay next release to finish work on #33 but please let me know if need it earlier or have an opinion about new api.

@danielroe
Copy link
Member Author

danielroe commented May 22, 2024

No worries at all; there's no rush. I like the perf suggestion too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants