From 32815d8d9bec6c1efe58f4fcdcd226b1e47364ce Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 15 Feb 2024 16:28:59 +0000 Subject: [PATCH] Quick readability enhancement. --- packages/server/src/utilities/workerRequests.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/server/src/utilities/workerRequests.ts b/packages/server/src/utilities/workerRequests.ts index def3ffe9cf..054514ab59 100644 --- a/packages/server/src/utilities/workerRequests.ts +++ b/packages/server/src/utilities/workerRequests.ts @@ -64,12 +64,7 @@ export function createRequest(request: Request): RequestInit { if (value === undefined) { continue } - - if (Array.isArray(value)) { - headers[header] = value[0] - } else { - headers[header] = value - } + headers[header] = Array.isArray(value) ? value[0] : value } // be specific about auth headers const cookie = ctx.headers[constants.Header.COOKIE], @@ -77,11 +72,9 @@ export function createRequest(request: Request): RequestInit { if (cookie) { headers[constants.Header.COOKIE] = cookie } else if (apiKey) { - if (Array.isArray(apiKey)) { - headers[constants.Header.API_KEY] = apiKey[0] - } else { - headers[constants.Header.API_KEY] = apiKey - } + headers[constants.Header.API_KEY] = Array.isArray(apiKey) + ? apiKey[0] + : apiKey } }