Browse Source

Safely unwrap URL host

This commit fixes a crash that happens when the user attempts to
navigate to `gemini://'.

Castor now displays an error message:

    Could not connect to :1965
master
Mark Dain 5 months ago
parent
commit
35a0f3649f
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      src/gemini/client.rs

+ 1
- 1
src/gemini/client.rs View File

@@ -8,7 +8,7 @@ use crate::protocols::*;
8 8
 
9 9
 pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), String> {
10 10
     let url = url.get_source_url();
11
-    let host = url.host_str().unwrap();
11
+    let host = url.host_str().unwrap_or("");
12 12
     let port = url.port().unwrap_or(1965);
13 13
     let urlf = format!("{}:{}", host, port);
14 14
 

Loading…
Cancel
Save