From caeddebbb83e0ea0f495d1ce598f7daa288591e4 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 24 Jul 2024 00:38:05 +0000 Subject: refactor(response): move configuration into struct --- src/html.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/html.rs') 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 { 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() { -- cgit v1.2.3