mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-02 06:26:10 -04:00
Allow directory listing work with or without trailing slash (removing trailing slash by default), and make directory listing links absolute instead of relative
This commit is contained in:
parent
8a45de8241
commit
e950cc5fe8
3 changed files with 75 additions and 60 deletions
|
@ -71,6 +71,9 @@ class WebsiteModeWeb(SendBaseModeWeb):
|
|||
self.web.cancel_compression = True
|
||||
|
||||
def render_logic(self, path=""):
|
||||
# Strip trailing slash
|
||||
path = path.rstrip("/")
|
||||
|
||||
if path in self.files:
|
||||
filesystem_path = self.files[path]
|
||||
|
||||
|
@ -86,10 +89,7 @@ class WebsiteModeWeb(SendBaseModeWeb):
|
|||
# Otherwise, render directory listing
|
||||
filenames = []
|
||||
for filename in os.listdir(filesystem_path):
|
||||
if os.path.isdir(os.path.join(filesystem_path, filename)):
|
||||
filenames.append(filename + "/")
|
||||
else:
|
||||
filenames.append(filename)
|
||||
filenames.append(filename)
|
||||
filenames.sort()
|
||||
return self.directory_listing(filenames, path, filesystem_path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue