Skip to content

Commit

Permalink
proper sort filename
Browse files Browse the repository at this point in the history
  • Loading branch information
joknarf committed Dec 26, 2024
1 parent bbc95eb commit 8c021b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pywebfs/pywebfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import urllib
import html
import base64
import unicodedata
from functools import lru_cache

# python 3.6 no TheedingHTTPServer
Expand Down Expand Up @@ -529,6 +530,7 @@
"""
#JAVASCRIPT=f"<script>\n{JAVASCRIPT}\n</script>"
RE_AGENT = re.compile(r"(Edg|Chrome|Safari|Firefox|Opera|Lynx)[^ ]*")
RE_ACCENT = re.compile(r"[\u0300-\u036f]")

class BadStat:
st_size = 0
Expand Down Expand Up @@ -948,7 +950,10 @@ def list_directory(self, path):
self.write_html("</tbody></table>\n")
self.write_html('<p id="info">0 file - 0 B</p>\n')
return
entries = sorted(entries, key=lambda entry: (not entry.is_dir(), entry.name.lower()))
entries = sorted(entries, key=lambda entry: (
not entry.is_dir(),
RE_ACCENT.sub("", unicodedata.normalize("NFD", entry.name.lower()))
))
nbfiles = 0
size = 0
for entry in entries:
Expand Down

0 comments on commit 8c021b8

Please sign in to comment.