From 6008d165a3d80b322f2d25dc43759c1ba5ae67dc Mon Sep 17 00:00:00 2001 From: Sander Koenders Date: Tue, 31 Oct 2023 12:49:55 +0100 Subject: [PATCH] Use nullish coalescing to determine path We are currently struggling with a situation where `/test` proxies to a lambda. This causes `event.pathParameters.proxy` to be `undefined`. The request is then translated to `/test` rather than `/`. To solve this we want to overwrite `event.pathParameters.proxy` with an empty string but the absence of nullish coalescing causes this to still use the `event.path` rather than `event.pathParameters.proxy` --- src/event-sources/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/event-sources/utils.js b/src/event-sources/utils.js index c5537e12..714e0f99 100644 --- a/src/event-sources/utils.js +++ b/src/event-sources/utils.js @@ -4,7 +4,7 @@ function getPathWithQueryStringParams ({ event, query = event.multiValueQueryStringParameters, // NOTE: Use `event.pathParameters.proxy` if available ({proxy+}); fall back to `event.path` - path = (event.pathParameters && event.pathParameters.proxy && `/${event.pathParameters.proxy}`) || event.path, + path = (event.pathParameters && event.pathParameters.proxy && `/${event.pathParameters.proxy}`) ?? event.path, // NOTE: Strip base path for custom domains stripBasePath = '', replaceRegex = new RegExp(`^${stripBasePath}`)