diff options
author | 2023-10-04 10:28:36 +0000 | |
---|---|---|
committer | 2023-10-04 18:28:36 +0800 | |
commit | ececd7fb4f50474a743f07e4747c23c1fc8a562a (patch) | |
tree | d1e8b540bf907a771ae398a0a9dbd028645b609d /packages/integrations/node/src | |
parent | 7bc3fb2763623097700cca716e8517b289b2f931 (diff) | |
download | astro-ececd7fb4f50474a743f07e4747c23c1fc8a562a.tar.gz astro-ececd7fb4f50474a743f07e4747c23c1fc8a562a.tar.zst astro-ececd7fb4f50474a743f07e4747c23c1fc8a562a.zip |
chore: remove undici polyfill (#8729)
Diffstat (limited to 'packages/integrations/node/src')
-rw-r--r-- | packages/integrations/node/src/createOutgoingHttpHeaders.ts | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/packages/integrations/node/src/createOutgoingHttpHeaders.ts b/packages/integrations/node/src/createOutgoingHttpHeaders.ts index e6c0c0ba4..a2f9b74e8 100644 --- a/packages/integrations/node/src/createOutgoingHttpHeaders.ts +++ b/packages/integrations/node/src/createOutgoingHttpHeaders.ts @@ -8,15 +8,12 @@ import type { OutgoingHttpHeaders } from 'node:http'; * @returns NodeJS OutgoingHttpHeaders object with multiple set-cookie handled as an array of values */ export const createOutgoingHttpHeaders = ( - webHeaders: Headers | undefined | null + headers: Headers | undefined | null ): OutgoingHttpHeaders | undefined => { - if (!webHeaders) { + if (!headers) { return undefined; } - - // re-type to access Header.getSetCookie() - const headers = webHeaders as HeadersWithGetSetCookie; - + // at this point, a multi-value'd set-cookie header is invalid (it was concatenated as a single CSV, which is not valid for set-cookie) const nodeHeaders: OutgoingHttpHeaders = Object.fromEntries(headers.entries()); @@ -26,7 +23,8 @@ export const createOutgoingHttpHeaders = ( // if there is > 1 set-cookie header, we have to fix it to be an array of values if (headers.has('set-cookie')) { - const cookieHeaders = headers.getSetCookie(); + // @ts-expect-error + const cookieHeaders = headers.getSetCookie() as string[]; if (cookieHeaders.length > 1) { // the Headers.entries() API already normalized all header names to lower case so we can safely index this as 'set-cookie' nodeHeaders['set-cookie'] = cookieHeaders; @@ -35,8 +33,3 @@ export const createOutgoingHttpHeaders = ( return nodeHeaders; }; - -interface HeadersWithGetSetCookie extends Headers { - // the @astrojs/webapi polyfill makes this available (as of undici@5.19.0), but tsc doesn't pick it up on the built-in Headers type from DOM lib - getSetCookie(): string[]; -} |