Safely unwrap URL host v1 APPLIED

Mark Dain: 1
 Safely unwrap URL host

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~julienxx/asuka/patches/20690/mbox | git am -3
Learn more about email & git

[PATCH] Safely unwrap URL host Export this patch

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

With this fix, Asuka now displays an error message:

    Could not connect to :1965
    failed to lookup address information: Name or service not known
 src/content.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/content.rs b/src/content.rs
index 184d9e4..02fdc41 100644
--- a/src/content.rs
+++ b/src/content.rs
@@ -6,7 +6,7 @@ use std::net::{TcpStream, ToSocketAddrs};
use std::time::Duration;

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

    let mut builder = TlsConnector::builder();