From 333283398ecebc1657e567485a48ec0a677ea353 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 8 Dec 2023 17:29:43 +0100 Subject: [PATCH] automatically add missing index.html from path. --- src/bin/server.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/bin/server.rs b/src/bin/server.rs index 4db04bc..205e9d4 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -278,6 +278,19 @@ impl Thing { )); } } + Err(e) if e.kind() == ErrorKind::IsADirectory => { + return self.resp_redirect(&format!( + "/{}/{}/{}/{}index.html", + krate, + version, + flavor, + path[3..].iter().fold(String::new(), |mut s, p| { + s.push_str(p); + s.push('/'); + s + }) + )) + } x => x?, } .into_owned();