From e0b6bb28d6e4ae32539f5876ea73f914e4979031 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Fri, 20 Dec 2024 10:29:20 -0800 Subject: [PATCH] Small tweaks to Cookie constructor --- packages/headers/src/lib/cookie.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/headers/src/lib/cookie.ts b/packages/headers/src/lib/cookie.ts index d10d2e5..5ce079e 100644 --- a/packages/headers/src/lib/cookie.ts +++ b/packages/headers/src/lib/cookie.ts @@ -20,17 +20,15 @@ export class Cookie implements HeaderValue, Iterable<[string, string]> { if (typeof init === 'string') { let params = parseParams(init); for (let [name, value] of params) { - this.#map.set(name, value || ''); + this.#map.set(name, value ?? ''); } } else if (isIterable(init)) { for (let [name, value] of init) { this.#map.set(name, value); } } else { - for (let name in init) { - if (Object.prototype.hasOwnProperty.call(init, name)) { - this.#map.set(name, init[name]); - } + for (let name of Object.getOwnPropertyNames(init)) { + this.#map.set(name, init[name]); } } }