diff options
| author | Fuwn <[email protected]> | 2022-06-13 07:28:13 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-06-13 07:28:13 +0000 |
| commit | 8e5a7ef939ffa17b20fe309a8769292dda41ec68 (patch) | |
| tree | 147ed482cc8326c459e84cc5785c57b0d02e5244 /src | |
| parent | fix(gemini_to_html): circumlunar.space style urls (diff) | |
| download | september-8e5a7ef939ffa17b20fe309a8769292dda41ec68.tar.xz september-8e5a7ef939ffa17b20fe309a8769292dda41ec68.zip | |
fix(gemini_to_html): keep non gemini urls
Diffstat (limited to 'src')
| -rw-r--r-- | src/gemini_to_html.rs | 13 |
1 files changed, 9 insertions, 4 deletions
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); } |