From dc8c150ce8938f5805a525915634c49238ef4ecf Mon Sep 17 00:00:00 2001 From: Flummi Date: Sat, 15 Mar 2025 22:29:42 +0100 Subject: [PATCH] improve cookie handling by ensuring cookies are properly typed and refactor data event listener for consistency --- src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 601ad6e..610590b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -112,11 +112,12 @@ export default class Flummpress { searchParams: url.searchParams, qs: Object.fromEntries(url.searchParams.entries()), }; + req.cookies = {}; if(req.headers.cookie) { req.headers.cookie.split("; ").forEach(cookie => { const [key, value] = cookie.split("="); - req.cookies[key] = decodeURIComponent(value); + req.cookies![key] = decodeURIComponent(value); }); } } @@ -130,7 +131,7 @@ export default class Flummpress { return new Promise((resolve, reject) => { let body = ""; - req.on("data", (chunk) => { + req.on("data", chunk => { body += chunk; });