cookie
cookie copied to clipboard
Update serialize to accept a object of key/values.
The serialize method should be updated to accept an object of key/values and serialize to a cookie string. This would make the serialize/parse methods complement each other.
I could agree with that. PR would be appreciated.
@frogcjn It looks like #47 is a PR for this functionality.
@dougwilson This issue should be closed and marked as a duplicate, right?
This issue should be closed and marked as a duplicate, right?
Why? This issue was opening prior to that PR, so if anything should be closed for being a duplicate, it should be the PR, right?
@dougwilson I didn't see that the PR (#47) referenced this issue in the description:
Resolves #30
So, in my view, yes this issue should stay open until the PR has been merged.
I have another use-case for Cookie.serialize
to accept objects that goes beyond Set-Cookie
, which you may not have considered.
I'm building a WebExtension that modifies the Cookie
header of requests going out of the browser. This library has been very useful in parsing the cookies into objects, but isn't as convenient to serialize them back to a single Cookie
line.
I realize that mine is probably an edge-case, but I found it surprising that the parse, and serialize do not compliment one another. i.e, Cookie.serialize(Cookie.parse(str)) === str
Hi @gurupras , I don't think this issue will help you, though, because this proposal will still not make them compliment one another as you're expecting, as Cookie.serialize
creates Set-Cookie
header format and not the Cookie
header format. Accepting an object (as in this proposal) would not change that; it sounds like you are make a separate request from the one in this issue.
I have wanted this feature recently and updated it to create a new PR against the current state of the main branch.
#119