From 4de1259b2d17fd8df94fd05767d9581fb16bde6c Mon Sep 17 00:00:00 2001 From: Timur Sevimli Date: Tue, 22 Aug 2023 12:02:56 +0300 Subject: [PATCH] Fix root basename --- JavaScript/d-messenger/lib/static.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JavaScript/d-messenger/lib/static.js b/JavaScript/d-messenger/lib/static.js index 7485035..5e9b8d0 100644 --- a/JavaScript/d-messenger/lib/static.js +++ b/JavaScript/d-messenger/lib/static.js @@ -28,7 +28,7 @@ module.exports = (root, port, console) => { .createServer(async (req, res) => { const url = req.url === '/' ? '/index.html' : req.url; const filePath = path.join(root, url); - if (!filePath.startsWith(root)) { + if (!filePath.startsWith(path.basename(root))) { res.statusCode = 404; return void res.end('"File is not found"'); }