Skip to content

Commit

Permalink
fix(response): handle non-trimmed redirect assumptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Jul 21, 2024
1 parent 836c7f7 commit 647e787
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
17 changes: 14 additions & 3 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 647e787

Please sign in to comment.