improve cookie handling by ensuring cookies are properly typed and refactor data event listener for consistency

This commit is contained in:
Flummi 2025-03-15 22:29:42 +01:00
parent edd50ef9b1
commit dc8c150ce8

View File

@ -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;
});