agate

Simple gemini server for static files
git clone https://github.com/mbrubeck/agate.git
Log | Files | Refs | README

commit a515d508ac3d2c565d429a9a255788754263ff3f
parent 80286a59fa9f0a6f37751a97c7a72d917587c44e
Author: Johann150 <johann.galle@protonmail.com>
Date:   Thu, 19 Nov 2020 22:21:57 +0100

do not redirect on empty path

also fixed the check for a trailing slash

Diffstat:
Msrc/main.rs | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -156,10 +156,12 @@ async fn send_response<W: Write + Unpin>(url: Url, stream: &mut W) -> Result { path.extend(segments); } if async_std::fs::metadata(&path).await?.is_dir() { - if url.as_str().ends_with('/') { + if url.path().ends_with('/') || url.path().is_empty() { + // if the path ends with a slash or the path is empty, the links will work the same + // without a redirect path.push("index.gmi"); } else { - // Send a redirect when the URL for a directory has no trailing slash. + // if client is not redirected, links may not work as expected without trailing slash return respond(stream, "31", &[url.as_str(), "/"]).await; } }