commit 972ecf8c1372d8b22d0ead0facdf33db80864185
parent 681ba770a11bb9e8a0143b1090dc0bdd0e67fb97
Author: Johann150 <johann.galle@protonmail.com>
Date: Sat, 16 Jan 2021 13:08:21 +0100
correctly redirect directories
cf. <https://lists.orbitalfox.eu/archives/gemini/2021/004827.html>
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
@@ -204,7 +204,9 @@ async fn send_response(url: Url, stream: &mut TlsStream<TcpStream>) -> Result {
}
} else {
// if client is not redirected, links may not work as expected without trailing slash
- return send_header(stream, 31, &[url.as_str(), "/"]).await;
+ let mut url = url;
+ url.set_path(&format!("{}/", url.path()));
+ return send_header(stream, 31, &[url.as_str()]).await;
}
}
}