Skip to content

Commit

Permalink
BREAKING(http/cookie): remove Cookies and SameSite type aliases (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervonb authored Feb 12, 2021
1 parent 2b14db3 commit 07050a8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions http/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import { assert } from "../_util/assert.ts";
import { toIMF } from "../datetime/mod.ts";

export type Cookies = Record<string, string>;

export interface Cookie {
/** Name of the cookie. */
name: string;
Expand All @@ -25,13 +23,11 @@ export interface Cookie {
httpOnly?: boolean;
/** Allows servers to assert that a cookie ought not to
* be sent along with cross-site requests. */
sameSite?: SameSite;
sameSite?: "Strict" | "Lax" | "None";
/** Additional key value pairs with the form "key=value" */
unparsed?: string[];
}

export type SameSite = "Strict" | "Lax" | "None";

const FIELD_CONTENT_REGEXP = /^(?=[\x20-\x7E]*$)[^()@<>,;:\\"\[\]?={}\s]+$/;

function toString(cookie: Cookie): string {
Expand Down Expand Up @@ -146,10 +142,10 @@ function validateCookieValue(name: string, value: string | null): void {
* Parse the cookies of the Server Request
* @param req An object which has a `headers` property
*/
export function getCookies(req: { headers: Headers }): Cookies {
export function getCookies(req: { headers: Headers }): Record<string, string> {
const cookie = req.headers.get("Cookie");
if (cookie != null) {
const out: Cookies = {};
const out: Record<string, string> = {};
const c = cookie.split(";");
for (const kv of c) {
const [cookieKey, ...cookieVal] = kv.split("=");
Expand Down

0 comments on commit 07050a8

Please sign in to comment.