From bcddae5f00132c926869077032d5ff329369ac25 Mon Sep 17 00:00:00 2001 From: Robert Taylor Date: Mon, 28 Jun 2021 17:35:03 +0100 Subject: [PATCH] fix: Handle multiple cookies with the same name in the same way API Gateway does. --- .../http/lambda-events/LambdaProxyIntegrationEventV2.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js b/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js index 0ed58e952..5aa85ad6e 100644 --- a/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js +++ b/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js @@ -118,8 +118,13 @@ export default class LambdaProxyIntegrationEventV2 { const requestTime = formatToClfTime(received) const requestTimeEpoch = received - const cookies = Object.entries(this.#request.state).map( - ([key, value]) => `${key}=${value}`, + const cookies = Object.entries(this.#request.state).flatMap( + ([key, value]) => { + if (Array.isArray(value)) { + return value.map((v) => `${key}=${v}`) + } + return `${key}=${value}` + }, ) return {