From af3817c68db610853a6fb4e46bab7966046eef66 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 29 Jun 2021 11:14:00 +0200 Subject: 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. --- src/Cana/Extra.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3