1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

WebServer: Append trailing slash for directory links

This adds trailing slashes to all links to directories (when listing the
directory contents). This avoids the redirect that would otherwise
happen when browsing to those directories.
This commit is contained in:
Max Wipfli 2021-06-07 13:28:51 +02:00 committed by Andreas Kling
parent e4f3a5fe37
commit 2c5a8462ec

View file

@ -237,6 +237,10 @@ void Client::handle_directory_listing(String const& requested_path, String const
builder.appendff("<td><div class=\"{}\"></div></td>", is_directory ? "folder" : "file");
builder.append("<td><a href=\"");
builder.append(URL::percent_encode(name));
// NOTE: For directories, we append a slash so we don't always hit the redirect case,
// which adds a slash anyways.
if (is_directory)
builder.append('/');
builder.append("\">");
builder.append(escape_html_entities(name));
builder.append("</a></td><td>&nbsp;</td>");