aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2021-06-29 11:14:00 +0200
committerDaniel Schadt <kingdread@gmx.de>2021-06-29 11:14:00 +0200
commitaf3817c68db610853a6fb4e46bab7966046eef66 (patch)
treec15bce156927d41245c853d21060a8d33ada9da6 /src
parentdce5159d2a7c8d2043a9686cbeca76fec69fac87 (diff)
downloadCana-af3817c68db610853a6fb4e46bab7966046eef66.tar.gz
Cana-af3817c68db610853a6fb4e46bab7966046eef66.tar.bz2
Cana-af3817c68db610853a6fb4e46bab7966046eef66.zip
fix handling of empty path segment
Now, 'gemini://localhost' is treated the same as 'gemini://localhost/', and will display the index instead of raising a 51.
Diffstat (limited to 'src')
-rw-r--r--src/Cana/Extra.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Cana/Extra.hs b/src/Cana/Extra.hs
index c776160..efcdb8c 100644
--- a/src/Cana/Extra.hs
+++ b/src/Cana/Extra.hs
@@ -44,7 +44,8 @@ geminiMime = "text/gemini"
staticFiles :: FilePath -- ^ Base directory where static files are searched.
-> Handler
staticFiles basedir request = do
- let reqPath = sanitize . uriPath . requestUri $ request
+ let reqPath' = uriPath . requestUri $ request
+ reqPath = if null reqPath' then "/" else sanitize reqPath'
fsPath = basedir ++ reqPath
notFoundResponse = GeminiResponse
{ responseStatus = codeNotFound