From ca8aadf5a913f50205e37ddf25d2960ef3b9dbdb Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 17 Jul 2022 11:36:29 +0000 Subject: fix(input.rs): error handle open command --- src/input.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/input.rs b/src/input.rs index 54065ac..56a4fd7 100644 --- a/src/input.rs +++ b/src/input.rs @@ -16,7 +16,7 @@ // SPDX-License-Identifier: GPL-3.0-only use crossterm::event::KeyCode; -use url::Url; +use url::{Url}; use crate::command::Command; @@ -162,15 +162,18 @@ fn handle_editing_input( Command::Quit => return true, Command::Open(to) => if let Some(to) = to { - app.set_url( - Url::parse(&if to.starts_with("gemini://") { - to - } else { - format!("gemini://{}", to) - }) - .unwrap(), - ); - app.make_request(); + match + Url::parse(&if to.starts_with("gemini://") { + to + } else { + format!("gemini://{}", to) + }) { + Ok(url) => { + app.set_url(url); + app.make_request(); + } + Err(error) => app.error = Some(error.to_string()), + } } else { app.error = Some("No URL provided for open command".to_string()); }, -- cgit v1.2.3