Skip to content

Commit

Permalink
WebServer: Sort entries in directory listing
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxWipfli authored and awesomekling committed Jun 11, 2021
1 parent 2c5a846 commit 977b350
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Userland/Services/WebServer/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/MemoryStream.h>
#include <AK/QuickSort.h>
#include <AK/StringBuilder.h>
#include <AK/URL.h>
#include <LibCore/DateTime.h>
Expand Down Expand Up @@ -211,9 +212,12 @@ void Client::handle_directory_listing(String const& requested_path, String const
builder.append("<code><table>\n");

Core::DirIterator dt(real_path);
while (dt.has_next()) {
auto name = dt.next_path();
Vector<String> names;
while (dt.has_next())
names.append(dt.next_path());
quick_sort(names);

for (auto& name : names) {
StringBuilder path_builder;
path_builder.append(real_path);
path_builder.append('/');
Expand Down

0 comments on commit 977b350

Please sign in to comment.