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

WebServer: Use relative URLs for the directory listing

This fixes an issue found on Linus's hosted WebServer. Now, if WebServer
is hosted at a non-root URL. (eg, `example.com/webserver` instead of
`example.com`) the links will correctly go to
`example.com/webserver/foo` instead of `example.com/foo`.
This commit is contained in:
Sam Atkins 2023-03-27 14:40:15 +01:00 committed by Sam Atkins
parent cce5e3158f
commit 7dfe1f9f8f

View file

@ -313,7 +313,7 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
builder.append("<tr>"sv);
builder.appendff("<td><div class=\"{}\"></div></td>", is_directory ? "folder" : "file");
builder.append("<td><a href=\""sv);
builder.append("<td><a href=\"./"sv);
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.