Опубликовано через кнопку

This commit is contained in:
dauren 2026-09-18 05:20:28 +00:00
parent dd46711a00
commit e65b48ba45

View File

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