Skip to content

Commit

Permalink
Merge pull request #64 from weglot/master
Browse files Browse the repository at this point in the history
Add partitioned attribute support
  • Loading branch information
nfriedly authored Jul 31, 2024
2 parents 0b05cf2 + a14d264 commit 55b53ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Returns either an array of cookie objects or a map of name => cookie object with
* `secure` - indicates that this cookie should only be sent over HTTPs (true or undefined)
* `httpOnly` - indicates that this cookie should *not* be accessible to client-side JavaScript (true or undefined)
* `sameSite` - indicates a cookie ought not to be sent along with cross-site requests (string or undefined)
* `partitioned` - indicates that this cookie could be created in an iframe from a 3rd party domain (true or undefined)

(The output format is loosely based on the input format of https://www.npmjs.com/package/cookie)

Expand Down
2 changes: 2 additions & 0 deletions lib/set-cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function parseString(setCookieValue, options) {
cookie.httpOnly = true;
} else if (key === "samesite") {
cookie.sameSite = value;
} else if (key === "partitioned") {
cookie.partitioned = true;
} else {
cookie[key] = value;
}
Expand Down
3 changes: 2 additions & 1 deletion test/set-cookie-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("set-cookie-parser", function () {

it("should parse a complex set-cookie header", function () {
var cookieStr =
"foo=bar; Max-Age=1000; Domain=.example.com; Path=/; Expires=Tue, 01 Jul 2025 10:01:11 GMT; HttpOnly; Secure";
"foo=bar; Max-Age=1000; Domain=.example.com; Path=/; Expires=Tue, 01 Jul 2025 10:01:11 GMT; HttpOnly; Secure; Partitioned";
var actual = setCookie.parse(cookieStr);
var expected = [
{
Expand All @@ -40,6 +40,7 @@ describe("set-cookie-parser", function () {
domain: ".example.com",
secure: true,
httpOnly: true,
partitioned: true,
},
];
assert.deepEqual(actual, expected);
Expand Down

0 comments on commit 55b53ca

Please sign in to comment.