Skip to content

Commit

Permalink
Small tweaks to Cookie constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Dec 20, 2024
1 parent 52f57b9 commit e0b6bb2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/headers/src/lib/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
Expand Down

0 comments on commit e0b6bb2

Please sign in to comment.