From b14d3b30cad577bb3b233072d99f375e6bb7fd26 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 13 Jun 2022 07:28:13 +0000 Subject: fix(gemini_to_html): keep non gemini urls --- src/gemini_to_html.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs index 777381a..870910b 100644 --- a/src/gemini_to_html.rs +++ b/src/gemini_to_html.rs @@ -56,8 +56,11 @@ pub fn gemini_to_html( text, } => { let mut href = to.clone(); + let mut surface = false; - if !href.starts_with("gemini://") && !href.starts_with('/') { + if href.contains("://") && !href.starts_with("gemini://") { + surface = true; + } else if !href.starts_with("gemini://") && !href.starts_with('/') { href = format!("./{}", href); } else if href.starts_with('/') || !href.contains("://") { href = link_from_host_href(url, &href); @@ -66,6 +69,7 @@ pub fn gemini_to_html( if var("PROXY_BY_DEFAULT").unwrap_or_else(|_| "true".to_string()) == "true" && href.contains("gemini://") + && !surface { if is_proxy || href @@ -88,7 +92,7 @@ pub fn gemini_to_html( if let Ok(keeps) = var("KEEP_GEMINI_EXACT") { let mut keeps = keeps.split(','); - if href.starts_with('/') || !href.contains("://") { + if (href.starts_with('/') || !href.contains("://")) && !surface { let temporary_href = link_from_host_href(url, &href); if keeps.any(|k| k == &*temporary_href) { @@ -98,9 +102,10 @@ pub fn gemini_to_html( } if let Ok(keeps) = var("KEEP_GEMINI_DOMAIN") { - if href.starts_with('/') + if (href.starts_with('/') || !href.contains("://") - && keeps.split(',').any(|k| k == &*url.authority.host) + && keeps.split(',').any(|k| k == &*url.authority.host)) + && !surface { href = link_from_host_href(url, &href); } -- cgit v1.2.3