-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left a few comments. Btw, when adding .travis.yml
, I recommend adding Node.js v4 and v9 to the matrix to match Elastic APM
class SetCookie { | ||
constructor (input, options) { | ||
if (Array.isArray(input)) { | ||
return input.map(item => new SetCookie(item, options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work if people do new SetCookie(array)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it will return an array of SetCookie instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will return statements not be ignored inside of a constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, if you return in a constructor, the return value of the new Constructor
will be whatever was returned. 😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests prove this already, by the way. 😸
index.js
Outdated
maxAge: undefined, | ||
domain: undefined, | ||
path: undefined, | ||
secure: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider setting this default value to false
index.js
Outdated
domain: undefined, | ||
path: undefined, | ||
secure: undefined, | ||
httpOnly: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider setting this default value to false
index.js
Outdated
} | ||
|
||
data = { | ||
key: this[decode](pair[0]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie:
__Secure-
prefix: Cookies with a name starting with__Secure-
(dash is part of the prefix) must be set with thesecure
flag and must be from a secure page (HTTPS).__Host-
prefix: Cookies with a name starting with__Host-
must be set with thesecure
flag, must be from a secure page (HTTPS), must not have a domain specified (and therefore aren't sent to subdomains) and the path must be "/".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider this?
@watson Can I get another review of this? |
This is an initial implementation of a set-cookie parser and serializer.