1
0
Fork 0
forked from svrjs/svrjs

Optimized bad (broken) entry generation in directory listing

This commit is contained in:
Dorian Niemiec 2024-03-17 00:57:47 +01:00
parent c44c796253
commit f1c74cb036

12
svr.js
View file

@ -3703,25 +3703,15 @@ if (!cluster.isPrimary) {
var estats = filelist[i].stats; var estats = filelist[i].stats;
var ename = filelist[i].name; var ename = filelist[i].name;
if (filelist[i].errored) { if (filelist[i].errored) {
if (estats) {
directoryListingRows.push( directoryListingRows.push(
"<tr><td style=\"width: 24px;\"><img src=\"/.dirimages/bad.png\" alt=\"[BAD]\" width=\"24px\" height=\"24px\" /></td><td style=\"word-wrap: break-word; word-break: break-word; overflow-wrap: break-word;\"><a href=\"" + "<tr><td style=\"width: 24px;\"><img src=\"/.dirimages/bad.png\" alt=\"[BAD]\" width=\"24px\" height=\"24px\" /></td><td style=\"word-wrap: break-word; word-break: break-word; overflow-wrap: break-word;\"><a href=\"" +
(href + "/" + encodeURI(ename)).replace(/\/+/g, "/") + (href + "/" + encodeURI(ename)).replace(/\/+/g, "/") +
"\"><nocode>" + "\"><nocode>" +
ename.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") + ename.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") +
"</nocode></a></td><td>-</td><td>" + "</nocode></a></td><td>-</td><td>" +
estats.mtime.toDateString() + (estats ? estats.mtime.toDateString() : "-") +
"</td></tr>\r\n" "</td></tr>\r\n"
); );
} else {
directoryListingRows.push(
"<tr><td style=\"width: 24px;\"><img src=\"/.dirimages/bad.png\" alt=\"[BAD]\" width=\"24px\" height=\"24px\" /></td><td style=\"word-wrap: break-word; word-break: break-word; overflow-wrap: break-word;\"><a href=\"" +
(href + "/" + encodeURI(ename)).replace(/\/+/g, "/") +
"\"><nocode>" +
ename.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") +
"</nocode></a></td><td>-</td><td>-</td></tr>\r\n"
);
}
} else { } else {
var entry = "<tr><td style=\"width: 24px;\"><img src=\"[img]\" alt=\"[alt]\" width=\"24px\" height=\"24px\" /></td><td style=\"word-wrap: break-word; word-break: break-word; overflow-wrap: break-word;\"><a href=\"" + var entry = "<tr><td style=\"width: 24px;\"><img src=\"[img]\" alt=\"[alt]\" width=\"24px\" height=\"24px\" /></td><td style=\"word-wrap: break-word; word-break: break-word; overflow-wrap: break-word;\"><a href=\"" +
(origHref + "/" + encodeURIComponent(ename)).replace(/\/+/g, "/") + (origHref + "/" + encodeURIComponent(ename)).replace(/\/+/g, "/") +