Add trailing slash in dir listing

This commit is contained in:
Lauri Kasanen 2021-04-22 11:33:05 +03:00
parent f64bd4f1a4
commit 14e08a2067

View File

@ -779,7 +779,13 @@ static void dirlisting(ws_ctx_t *ws_ctx, const char fullpath[], const char path[
if (!strcmp(names[i]->d_name, ".") || !strcmp(names[i]->d_name, ".."))
continue;
sprintf(buf, "<li><a href=\"%s\">%s</a></li>", names[i]->d_name, names[i]->d_name);
if (names[i]->d_type == DT_DIR)
sprintf(buf, "<li><a href=\"%s/\">%s/</a></li>", names[i]->d_name,
names[i]->d_name);
else
sprintf(buf, "<li><a href=\"%s\">%s</a></li>", names[i]->d_name,
names[i]->d_name);
ws_send(ws_ctx, buf, strlen(buf));
}