Опубликовано через кнопку
This commit is contained in:
parent
dd46711a00
commit
e65b48ba45
@ -52,8 +52,9 @@ http.createServer(async (req, res) => {
|
|||||||
return res.end(JSON.stringify({ ok: true, id: rec.id }));
|
return res.end(JSON.stringify({ ok: true, id: rec.id }));
|
||||||
}
|
}
|
||||||
|
|
||||||
const safe = decodeURIComponent(url);
|
const safe = decodeURIComponent(url) || "/";
|
||||||
const full = path.join(__dirname, safe);
|
let file = safe === "/" ? "/index.html" : safe;
|
||||||
|
const full = path.join(__dirname, file);
|
||||||
if (full.startsWith(__dirname) && fs.existsSync(full) && fs.statSync(full).isFile()) {
|
if (full.startsWith(__dirname) && fs.existsSync(full) && fs.statSync(full).isFile()) {
|
||||||
const ext = path.extname(full).toLowerCase();
|
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" };
|
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" };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user