diff options
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/response.rs | 17 |
3 files changed, 16 insertions, 5 deletions
@@ -1839,7 +1839,7 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "september" -version = "0.2.25" +version = "0.2.26" dependencies = [ "actix-web", "anyhow", @@ -2,7 +2,7 @@ [package] name = "september" -version = "0.2.25" +version = "0.2.26" authors = ["Fuwn <[email protected]>"] edition = "2021" description = "A simple and efficient Gemini-to-HTTP proxy." diff --git a/src/response.rs b/src/response.rs index 07161d5..3986b5a 100644 --- a/src/response.rs +++ b/src/response.rs @@ -58,7 +58,10 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< } }; - if response.content().is_none() { + if response.content().is_none() + && response.status() != &germ::request::Status::PermanentRedirect + && response.status() != &germ::request::Status::TemporaryRedirect + { response = match germ::request::request(&match url_from_path( req.path().trim_end_matches('/'), true, @@ -211,8 +214,16 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< )); let redirect_url = match url_from_path( - response.meta().trim_end_matches('/'), - true, + &if response.meta().trim_end_matches('/').starts_with('/') { + format!( + "/proxy/{}{}", + url.domain().unwrap_or_default(), + response.meta().trim_end_matches('/') + ) + } else { + response.meta().trim_end_matches('/').to_string() + }, + false, &mut is_proxy, &mut is_raw, &mut is_nocss, |