summaryrefslogtreecommitdiff
path: root/std/http/cookie.ts
diff options
context:
space:
mode:
author木杉 <zhmushan@qq.com>2020-04-10 22:12:42 +0800
committerGitHub <noreply@github.com>2020-04-10 10:12:42 -0400
commit195ad4c6264c3563044480685931999ffa9d3d5c (patch)
treec95503b6845acfcbb76de6901f3dd7b4cad81a1c /std/http/cookie.ts
parent85c61bff1cee2344646b533b96a4b5c1a67a5850 (diff)
fix(std/http): verify cookie name & update SameSite type (#4685)
Diffstat (limited to 'std/http/cookie.ts')
-rw-r--r--std/http/cookie.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/std/http/cookie.ts b/std/http/cookie.ts
index 41d417518..22ecf3bc7 100644
--- a/std/http/cookie.ts
+++ b/std/http/cookie.ts
@@ -22,9 +22,12 @@ export interface Cookie {
unparsed?: string[];
}
-export type SameSite = "Strict" | "Lax";
+export type SameSite = "Strict" | "Lax" | "None";
function toString(cookie: Cookie): string {
+ if (!cookie.name) {
+ return "";
+ }
const out: string[] = [];
out.push(`${cookie.name}=${cookie.value}`);
@@ -115,7 +118,10 @@ export function setCookie(res: Response, cookie: Cookie): void {
// TODO (zekth) : Add proper parsing of Set-Cookie headers
// Parsing cookie headers to make consistent set-cookie header
// ref: https://tools.ietf.org/html/rfc6265#section-4.1.1
- res.headers.append("Set-Cookie", toString(cookie));
+ const v = toString(cookie);
+ if (v) {
+ res.headers.append("Set-Cookie", v);
+ }
}
/**