]> git.r.bdr.sh - rbdr/gema_texto/commitdiff
Address clippy main 1.0.1
authorRuben Beltran del Rio <redacted>
Mon, 13 Jan 2025 17:42:26 +0000 (18:42 +0100)
committerRuben Beltran del Rio <redacted>
Mon, 13 Jan 2025 17:42:26 +0000 (18:42 +0100)
src/html_renderer.rs

index fccf16350370fe432ac8435e544c3c7126d93033..61d2d733eb3240b1bd80a4047bddc962dcbdd1c0 100644 (file)
@@ -1,4 +1,5 @@
 use crate::gemini_parser::GeminiLine;
 use crate::gemini_parser::GeminiLine;
+use std::path::Path;
 
 /// Renders HTML from a vector of `GeminiLine` elements.
 ///
 
 /// 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!("<p>{content}</p>"),
         GeminiLine::Link(url, text) => {
     match line {
         GeminiLine::Text(content, false) => format!("<p>{content}</p>"),
         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 {
             } else {
-                processed_url = url.to_string();
-            }
+                url.to_string()
+            };
+
             let display = if text.is_empty() {
                 &processed_url
             } else {
             let display = if text.is_empty() {
                 &processed_url
             } else {