[PATCH taurus] Fix redirects for subdirectories with / at the end
Export this patch
---
src/main.rs | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index f3a4b86..5eb7d25 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -114,15 +114,16 @@ fn handle_client(mut stream: TlsStream<TcpStream>) -> Result<(), String> {
if path.exists() {
// If it's a directory, try to find index.gmi
if path.is_dir() {
- redirect(
- path.join("index.gmi")
- .iter()
- .skip(1)
- .collect::<path::PathBuf>()
- .to_str()
- .ok_or("Invalid Unicode".to_owned())?,
- &mut response,
- );
+ let redir_path = path
+ .join("index.gmi")
+ .iter()
+ .skip(1)
+ .collect::<path::PathBuf>()
+ .to_str()
+ .ok_or("Invalid Unicode".to_owned())?
+ .to_owned();
+
+ redirect(&("/".to_owned() + &redir_path), &mut response);
} else {
send_file(
path.to_str().ok_or("Invalid Unicode".to_owned())?,
--
2.29.2
Applied. Thanks!