aboutsummaryrefslogtreecommitdiff
path: root/src/html.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-07-24 00:38:05 +0000
committerFuwn <[email protected]>2024-07-24 00:38:05 +0000
commitcaeddebbb83e0ea0f495d1ce598f7daa288591e4 (patch)
tree7c1cd50dc598f17f0a6b006c6ff8f858cf18b39c /src/html.rs
parentchore: remove semi-outdated technical information (diff)
downloadseptember-caeddebbb83e0ea0f495d1ce598f7daa288591e4.tar.xz
september-caeddebbb83e0ea0f495d1ce598f7daa288591e4.zip
refactor(response): move configuration into struct
Diffstat (limited to 'src/html.rs')
-rw-r--r--src/html.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/html.rs b/src/html.rs
index 9203656..81012ed 100644
--- a/src/html.rs
+++ b/src/html.rs
@@ -13,7 +13,7 @@ fn link_from_host_href(url: &Url, href: &str) -> Option<String> {
pub fn from_gemini(
response: &germ::request::Response,
url: &Url,
- is_proxy: bool,
+ configuration: &crate::response::configuration::Configuration,
) -> Option<(String, String)> {
let ast_tree = germ::ast::Ast::from_string(
response.content().as_ref().map_or_else(String::default, String::clone),
@@ -92,7 +92,8 @@ pub fn from_gemini(
&& href.contains("gemini://")
&& !surface
{
- if is_proxy
+ if (configuration.is_proxy())
+ || configuration.is_no_css()
|| href
.trim_start_matches("gemini://")
.trim_end_matches('/')
@@ -102,7 +103,11 @@ pub fn from_gemini(
.unwrap()
!= &url.host().unwrap().to_string().as_str()
{
- href = format!("/proxy/{}", href.trim_start_matches("gemini://"));
+ href = format!(
+ "/{}/{}",
+ if configuration.is_no_css() { "nocss" } else { "proxy" },
+ href.trim_start_matches("gemini://")
+ );
} else {
href = href.trim_start_matches("gemini://").replacen(
&if let Some(host) = url.host() {