From: Ruben Beltran del Rio Date: Mon, 13 Jan 2025 17:42:26 +0000 (+0100) Subject: Address clippy X-Git-Tag: 1.0.1 X-Git-Url: https://git.r.bdr.sh/rbdr/gema_texto/commitdiff_plain/refs/heads/main?ds=sidebyside;hp=9d687f8c5a45f72cb0040bb2d0441d04ea9987fb Address clippy --- diff --git a/src/html_renderer.rs b/src/html_renderer.rs index fccf163..61d2d73 100644 --- a/src/html_renderer.rs +++ b/src/html_renderer.rs @@ -1,4 +1,5 @@ use crate::gemini_parser::GeminiLine; +use std::path::Path; /// Renders HTML from a vector of `GeminiLine` elements. /// @@ -99,12 +100,17 @@ fn line_content(line: &GeminiLine) -> String { match line { GeminiLine::Text(content, false) => format!("

{content}

"), GeminiLine::Link(url, text) => { - let processed_url; - if !url.starts_with("gemini:") && url.ends_with(".gmi") { - processed_url = url.replace(".gmi", ".html"); + let path = Path::new(url); + let processed_url = if !url.starts_with("gemini:") + && path + .extension() + .map_or(false, |ext| ext.eq_ignore_ascii_case("gmi")) + { + url.replace(".gmi", ".html") } else { - processed_url = url.to_string(); - } + url.to_string() + }; + let display = if text.is_empty() { &processed_url } else {