From 5b4f2a0983dc9be32c12800cd3e8f5d16b64b86f Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Thu, 19 Dec 2024 22:43:09 +0100 Subject: [PATCH] chore: release SVR.JS Cache mod 1.0.1 --- modInfo.json | 2 +- src/index.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modInfo.json b/modInfo.json index 9992553..4579193 100644 --- a/modInfo.json +++ b/modInfo.json @@ -1,4 +1,4 @@ { "name": "SVR.JS Cache mod", - "version": "1.0.0" + "version": "1.0.1" } diff --git a/src/index.js b/src/index.js index 30cdf56..55b920c 100644 --- a/src/index.js +++ b/src/index.js @@ -77,12 +77,14 @@ module.exports = function (req, res, logFacilities, config, next) { res.writeHead = function (statusCode, statusCodeDescription, headers) { const properHeaders = headers ? headers : statusCodeDescription; - Object.keys(properHeaders).forEach((key) => { - writtenHeaders[key.toLowerCase()] = properHeaders[key]; - }); + if (typeof properHeaders === "object" && properHeaders !== null) { + Object.keys(properHeaders).forEach((key) => { + writtenHeaders[key.toLowerCase()] = properHeaders[key]; + }); + } writtenStatusCode = statusCode; res.setHeader("X-SVRJS-Cache", "MISS"); - if (headers) { + if (headers || typeof statusCodeDescription !== "object") { originalWriteHead( writtenStatusCode, statusCodeDescription,