Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/set-cookie-parser/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ declare namespace parse {
/**
* indicates a cookie ought not to be sent along with cross-site requests
*/
sameSite?: string | undefined;
sameSite?: true | false | 'lax' | 'strict' | 'none' | undefined
}

interface CookieMap {
Expand Down
8 changes: 4 additions & 4 deletions types/set-cookie-parser/set-cookie-parser-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assert.strictEqual(cookies[0].value, "bar");

// Optional properties included test
const optionalIncluded =
"foo=bar; Max-Age=1000; Domain=.example.com; Path=/; Expires=Tue, 01 Jul 2025 10:01:11 GMT; HttpOnly; Secure; SameSite=Strict";
"foo=bar; Max-Age=1000; Domain=.example.com; Path=/; Expires=Tue, 01 Jul 2025 10:01:11 GMT; HttpOnly; Secure; SameSite=strict";
cookies = setCookie(optionalIncluded);
assert.strictEqual(cookies.length, 1);
assert.strictEqual(cookies[0].name, "foo");
Expand All @@ -30,7 +30,7 @@ assert.deepStrictEqual(cookies[0].expires, new Date("Tue Jul 01 2025 06:01:11 GM
assert.strictEqual(cookies[0].maxAge, 1000);
assert.strictEqual(cookies[0].httpOnly, true);
assert.strictEqual(cookies[0].secure, true);
assert.strictEqual(cookies[0].sameSite, "Strict");
assert.strictEqual(cookies[0].sameSite, "strict");

// Array of strings test
const arrayOfCookies = ["bam=baz", "foo=bar"];
Expand Down Expand Up @@ -125,7 +125,7 @@ assert.deepStrictEqual(cookiesMap, expectedCookiesMap);

// Call parseString function
const individualSetCookieHeader =
"user=%D0%98%D0%BB%D1%8C%D1%8F%20%D0%97%D0%B0%D0%B9%D1%86%D0%B5%D0%B2; Max-Age=1000; Domain=.example.com; Path=/; Expires=Tue, 01 Jul 2025 10:01:11 GMT; HttpOnly; Secure; SameSite=Strict";
"user=%D0%98%D0%BB%D1%8C%D1%8F%20%D0%97%D0%B0%D0%B9%D1%86%D0%B5%D0%B2; Max-Age=1000; Domain=.example.com; Path=/; Expires=Tue, 01 Jul 2025 10:01:11 GMT; HttpOnly; Secure; SameSite=strict";
const decodedValueCookie = setCookie.parseString(individualSetCookieHeader);
const notDecodedValueCookie = setCookie.parseString(individualSetCookieHeader, { decodeValues: false });
const expectedCookie: setCookie.Cookie = {
Expand All @@ -137,7 +137,7 @@ const expectedCookie: setCookie.Cookie = {
expires: new Date("Tue, 01 Jul 2025 10:01:11 GMT"),
httpOnly: true,
secure: true,
sameSite: "Strict",
sameSite: "strict",
};
assert.deepStrictEqual(decodedValueCookie, expectedCookie);
assert.strictEqual(notDecodedValueCookie.value, "%D0%98%D0%BB%D1%8C%D1%8F%20%D0%97%D0%B0%D0%B9%D1%86%D0%B5%D0%B2");