~julienxx/castor

35a0f3649f1b2f33561f86af51b2ad7115d622bc — Mark Dain 6 months ago b41aef9
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
1 files changed, 1 insertions(+), 1 deletions(-)

M src/gemini/client.rs
M src/gemini/client.rs => src/gemini/client.rs +1 -1
@@ 8,7 8,7 @@ use crate::protocols::*;

pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), String> {
    let url = url.get_source_url();
    let host = url.host_str().unwrap();
    let host = url.host_str().unwrap_or("");
    let port = url.port().unwrap_or(1965);
    let urlf = format!("{}:{}", host, port);