diff options
author | 2023-10-04 10:28:36 +0000 | |
---|---|---|
committer | 2023-10-04 18:28:36 +0800 | |
commit | 21e0757ea22a57d344c934045ca19db93b684436 (patch) | |
tree | 52840800dc9e42633b2a266fa6bbbeb1f347ef46 /packages/integrations/node | |
parent | 272ad45958312b32afffbeff21a88891a2015f68 (diff) | |
download | astro-21e0757ea22a57d344c934045ca19db93b684436.tar.gz astro-21e0757ea22a57d344c934045ca19db93b684436.tar.zst astro-21e0757ea22a57d344c934045ca19db93b684436.zip |
chore: remove undici polyfill (#8729)
Diffstat (limited to 'packages/integrations/node')
-rw-r--r-- | packages/integrations/node/package.json | 3 | ||||
-rw-r--r-- | packages/integrations/node/src/createOutgoingHttpHeaders.ts | 17 |
2 files changed, 6 insertions, 14 deletions
diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 20739cbd7..865c1541d 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -49,8 +49,7 @@ "cheerio": "1.0.0-rc.12", "express": "^4.18.2", "mocha": "^10.2.0", - "node-mocks-http": "^1.13.0", - "undici": "^5.23.0" + "node-mocks-http": "^1.13.0" }, "publishConfig": { "provenance": true 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[]; -} |