Browse Source

[gopher] don't crash on schemes in text

"gemini:// " was crashing the link discovery
openbsd
Julien Blanchard 9 months ago
parent
commit
2210b43c04
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      src/gopher/link.rs

+ 6
- 2
src/gopher/link.rs View File

@@ -203,6 +203,10 @@ pub fn make_link(url: String, label: String) -> Option<Link> {
203 203
 fn extract_url(line: &str) -> &str {
204 204
     let finder = LinkFinder::new();
205 205
     let links: Vec<_> = finder.links(line).collect();
206
-    let link = &links[0];
207
-    link.as_str()
206
+    if links.is_empty() {
207
+        line
208
+    } else {
209
+        let link = &links[0];
210
+        link.as_str()
211
+    }
208 212
 }

Loading…
Cancel
Save