aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-02-05 18:36:40 +0100
committerbptato <nincsnevem662@gmail.com>2025-02-05 18:36:40 +0100
commit7093f5147c3ffac224eaae84fb986b1f65b39bbe (patch)
treef73bb77ef71c317c64f8617af0c2dd1226073b46
parent8db503b392040adec9742880991dc8a9d6f3bb7c (diff)
downloadchawan-7093f5147c3ffac224eaae84fb986b1f65b39bbe.tar.gz
file: fix directory listing
-rw-r--r--adapter/protocol/file.nim7
1 files changed, 3 insertions, 4 deletions
diff --git a/adapter/protocol/file.nim b/adapter/protocol/file.nim
index b18a3291..9d2c2758 100644
--- a/adapter/protocol/file.nim
+++ b/adapter/protocol/file.nim
@@ -77,14 +77,13 @@ proc loadFile(ps: PosixStream) =
proc main() =
let opath = getEnv("MAPPED_URI_PATH")
let path = percentDecode(opath)
- let ps = newPosixStream(path)
- if ps != nil:
- loadFile(ps)
- elif dirExists(path):
+ if dirExists(path):
if path[^1] != '/':
stdout.write("Status: 301\nLocation: " & path & "/\n")
else:
loadDir(path, opath)
+ elif (let ps = newPosixStream(path); ps != nil):
+ loadFile(ps)
else:
stdout.write("Cha-Control: ConnectionError FileNotFound")