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:
parent
e4f3a5fe37
commit
2c5a8462ec
1 changed files with 4 additions and 0 deletions
|
@ -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> </td>");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue