From bced5927fe4fb5e7ad08c33cdce13f1f0c85813c Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Tue, 27 Aug 2024 18:23:57 +0200 Subject: [PATCH] Replace ES5-style function in request handler with ES6-style ones --- src/handlers/requestHandler.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/handlers/requestHandler.js b/src/handlers/requestHandler.js index 99fedab..f5bc881 100644 --- a/src/handlers/requestHandler.js +++ b/src/handlers/requestHandler.js @@ -42,7 +42,7 @@ function requestHandler(req, res) { let ph = Object.assign({}, config.customHeaders); if (config.customHeadersVHost) { let vhostP = null; - config.customHeadersVHost.every(function (vhost) { + config.customHeadersVHost.every((vhost) => { if ( matchHostname(vhost.host, req.headers.host) && ipMatch(vhost.ip, req.socket ? req.socket.localAddress : undefined) @@ -55,12 +55,12 @@ function requestHandler(req, res) { }); if (vhostP && vhostP.headers) { const phNu = Object.assign({}, vhostP.headers); - Object.keys(phNu).forEach(function (phNuK) { + Object.keys(phNu).forEach((phNuK) => { ph[phNuK] = phNu[phNuK]; }); } } - Object.keys(ph).forEach(function (phk) { + Object.keys(ph).forEach((phk) => { if (typeof ph[phk] == "string") ph[phk] = ph[phk].replace(/\{path\}/g, req.url); }); @@ -77,7 +77,7 @@ function requestHandler(req, res) { res.writeHeadNodeApi = res.writeHead; res.setHeaderNodeApi = res.setHeader; - res.writeHead = function (a, b, c) { + res.writeHead = (a, b, c) => { let table = c; if (typeof b == "object") table = b; if (table == undefined) table = this.tHeaders; @@ -99,7 +99,7 @@ function requestHandler(req, res) { return res.writeHeadNodeApi(a, table); } }; - res.setHeader = function (headerName, headerValue) { + res.setHeader = (headerName, headerValue) => { const al = headerName.toLowerCase(); if ( al != "transfer-encoding" &&