1
0
Fork 0
forked from svrjs/svrjs

Fix "NaN" file sizes in directory listings

This commit is contained in:
Dorian Niemiec 2024-08-30 06:39:06 +02:00
parent e293c08592
commit 1444660d19
2 changed files with 2 additions and 2 deletions

View file

@ -773,7 +773,7 @@ module.exports = (req, res, logFacilities, config, next) => {
.replace(/>/g, "&gt;")}</a></td><td>${ .replace(/>/g, "&gt;")}</a></td><td>${
estats.isDirectory() estats.isDirectory()
? "-" ? "-"
: sizify(estats.size.toString()) : sizify(estats.size)
}</td><td>${estats.mtime.toDateString()}</td></tr>\r\n`; }</td><td>${estats.mtime.toDateString()}</td></tr>\r\n`;
// Determine the file type and set the appropriate image and alt text // Determine the file type and set the appropriate image and alt text

View file

@ -1,5 +1,5 @@
function sizify(bytes, addI) { function sizify(bytes, addI) {
if (bytes === 0) return "0"; if (bytes == 0) return "0";
if (bytes < 0) bytes = -bytes; if (bytes < 0) bytes = -bytes;
const prefixes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"]; const prefixes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];