From 8fb452c8fe98b927d7a8cacf0ce4fb6a2a34c12d Mon Sep 17 00:00:00 2001 From: Samuel Kopp <62482066+boywithkeyboard@users.noreply.github.com> Date: Thu, 22 Jun 2023 01:44:36 +0200 Subject: [PATCH] refactor(core): parse headers by default --- cheetah.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cheetah.ts b/cheetah.ts index 467f965..6eec11a 100644 --- a/cheetah.ts +++ b/cheetah.ts @@ -412,24 +412,24 @@ export class cheetah< let cookies: Record = {} let body - if (this.#validator && options) { - /* Parse Headers ------------------------------------------------------------ */ + let num = 0 - if (options.headers) { - let num = 0 + for (const [key, value] of request.headers) { + if (num === 50) { + break + } - for (const [key, value] of request.headers) { - if (num === 50) { - break - } + if (!headers[key.toLowerCase()]) { + headers[key.toLowerCase()] = value + } - if (!headers[key.toLowerCase()]) { - headers[key.toLowerCase()] = value - } + num++ + } - num++ - } + if (this.#validator && options) { + /* Parse Headers ------------------------------------------------------------ */ + if (options.headers) { const isValid = this.#validator.name === 'typebox' && this.#validator.check ? this.#validator.check(options.headers as TSchema, headers)