~garritfra/public-inbox

taurus: Fix redirects for subdirectories with / at the end v1 APPLIED

Alexey Yerin: 1
 Fix redirects for subdirectories with / at the end

 1 files changed, 10 insertions(+), 9 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~garritfra/public-inbox/patches/14872/mbox | git am -3
Learn more about email & git
View this thread in the archives

[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!