mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +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
Notes:
sideshowbarker
2024-07-18 12:26:42 +09:00
Author: https://github.com/MaxWipfli
Commit: 2c5a8462ec
Pull-request: https://github.com/SerenityOS/serenity/pull/7879
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/gunnarbeutner
Reviewed-by: https://github.com/linusg
Reviewed-by: https://github.com/stelar7
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