Skip to content

Commit

Permalink
Bug 1686488 [wpt PR 27148] - wptserve: correct sorting in DirectoryHa…
Browse files Browse the repository at this point in the history
…ndler, a=testonly

Automatic update from web-platform-tests
wptserve: correct sorting in DirectoryHandler

Found this while creating web-platform-tests/wpt#27129.

--

wpt-commits: b4c87a442f82ff5e1de9a94e735b7b6c5f2e60c5
wpt-pr: 27148
  • Loading branch information
annevk authored and moz-wptsync-bot committed Jan 15, 2021
1 parent 825eaa6 commit f2fb32e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def list_items(self, base_path, path):
{"link": link, "name": ".."})
items = []
prev_item = None
for item in sorted(os.listdir(path)):
# This ensures that .headers always sorts after the file it provides the headers for. E.g.,
# if we have x, x-y, and x.headers, the order will be x, x.headers, and then x-y.
for item in sorted(os.listdir(path), key=lambda x: (x[:-len(".headers")], x) if x.endswith(".headers") else (x, x)):
if prev_item and prev_item + ".headers" == item:
items[-1][1] = item
prev_item = None
Expand Down

0 comments on commit f2fb32e

Please sign in to comment.