Skip to content

Commit 9726d85

Browse files
committed
Small tweaks
1 parent 8baf875 commit 9726d85

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/headers/src/lib/set-cookie.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ export class SetCookie implements HeaderValue, SetCookieInit {
9595
break;
9696
case 'expires': {
9797
if (typeof value === 'string') {
98-
let v = new Date(value);
99-
if (isValidDate(v)) this.expires = v;
98+
let date = new Date(value);
99+
if (isValidDate(date)) {
100+
this.expires = date;
101+
}
100102
}
101103
break;
102104
}

packages/headers/src/lib/super-headers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type CookieInit, Cookie } from './cookie.ts';
77
import { canonicalHeaderName } from './header-names.ts';
88
import { type HeaderValue } from './header-value.ts';
99
import { type SetCookieInit, SetCookie } from './set-cookie.ts';
10-
import { isIterable, isValidDate } from './utils.ts';
10+
import { isIterable } from './utils.ts';
1111

1212
const CRLF = '\r\n';
1313
const SetCookieKey = 'set-cookie';
@@ -595,9 +595,9 @@ export class SuperHeaders extends Headers {
595595
}
596596
}
597597

598-
let header = new ctor();
599-
this.#map.set(key, header);
600-
return header;
598+
let obj = new ctor();
599+
this.#map.set(key, obj); // cache the new object
600+
return obj;
601601
}
602602

603603
#setHeaderValue(key: string, ctor: new (init?: string) => HeaderValue, value: any): void {

0 commit comments

Comments
 (0)