From e65b48ba45bb5cd6afd45855e8be5e8ab8923c71 Mon Sep 17 00:00:00 2001 From: dauren Date: Fri, 18 Sep 2026 05:20:28 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=BE=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 3385e09..3badb49 100644 --- a/server.js +++ b/server.js @@ -52,8 +52,9 @@ http.createServer(async (req, res) => { return res.end(JSON.stringify({ ok: true, id: rec.id })); } - const safe = decodeURIComponent(url); - const full = path.join(__dirname, safe); + const safe = decodeURIComponent(url) || "/"; + let file = safe === "/" ? "/index.html" : safe; + const full = path.join(__dirname, file); if (full.startsWith(__dirname) && fs.existsSync(full) && fs.statSync(full).isFile()) { const ext = path.extname(full).toLowerCase(); const types = { ".css": "text/css", ".js": "application/javascript", ".html": "text/html", ".png": "image/png", ".svg": "image/svg+xml", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".ico": "image/x-icon" };