Skip to content

Commit

Permalink
Style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Dec 21, 2024
1 parent e0c0f54 commit 906fa92
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/headers/src/lib/super-headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,23 +695,22 @@ export class SuperHeaders extends Headers {
* [HTTP/1.1 Specification](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1)
*/
get setCookie(): SetCookie[] {
for (let i = 0; i < this.#setCookies.length; ++i) {
let value = this.#setCookies[i];
if (typeof value === 'string') {
this.#setCookies[i] = new SetCookie(value);
let setCookies = this.#setCookies;

for (let i = 0; i < setCookies.length; ++i) {
if (typeof setCookies[i] === 'string') {
setCookies[i] = new SetCookie(setCookies[i]);
}
}

return this.#setCookies as SetCookie[];
return setCookies as SetCookie[];
}

set setCookie(value: (string | SetCookieInit)[] | string | SetCookieInit | undefined | null) {
if (value != null) {
if (Array.isArray(value)) {
this.#setCookies = value.map((v) => (typeof v === 'string' ? v : new SetCookie(v)));
} else {
this.#setCookies = [typeof value === 'string' ? value : new SetCookie(value)];
}
this.#setCookies = (Array.isArray(value) ? value : [value]).map((v) =>
typeof v === 'string' ? v : new SetCookie(v),
);
} else {
this.#setCookies = [];
}
Expand Down

0 comments on commit 906fa92

Please sign in to comment.