Skip to content

Commit

Permalink
feat(response): support redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Mar 24, 2024
1 parent 1046790 commit cf43656
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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.11"
version = "0.2.12"
authors = ["Fuwn <[email protected]>"]
edition = "2021"
description = "A simple and efficient Gemini-to-HTTP proxy."
Expand Down
14 changes: 14 additions & 0 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,20 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".<
germ::request::Status::Success => {
html_context.push_str(&gemini_html.1);
}
germ::request::Status::PermanentRedirect => {
html_context.push_str(&format!(
"<p>This page permanently redirects to <a href=\"{}\">{}</a>.</p>",
response.meta(),
response.meta().trim()
));
}
germ::request::Status::TemporaryRedirect => {
html_context.push_str(&format!(
"<p>This page temporarily redirects to <a href=\"{}\">{}</a>.</p>",
response.meta(),
response.meta().trim()
));
}
_ => html_context.push_str(&format!("<p>{}</p>", response.meta())),
}

Expand Down
1 change: 1 addition & 0 deletions src/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn make(
is_nocss: &mut bool,
) -> Result<Url, url::ParseError> {
Ok(
#[allow(clippy::blocks_in_conditions)]
match Url::try_from(&*if path.starts_with("/proxy") {
*is_proxy = true;

Expand Down

0 comments on commit cf43656

Please sign in to comment.