diff --git a/CHANGELOG.md b/CHANGELOG.md index f9bf818..b46fa15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Procedure when bumping the version number: - Respect colon-delimited emoji when calculating nick hue - Display colon-delimited emoji in nicks and messages - Non-export info is now printed to stderr instead of stdout +- Recognizes links without scheme (e. g. `euphoria.io` instead of `https://euphoria.io`) ### Fixed - Mentions not being stopped by `>` diff --git a/src/ui/euph/links.rs b/src/ui/euph/links.rs index 553e7ff..b1ebcb0 100644 --- a/src/ui/euph/links.rs +++ b/src/ui/euph/links.rs @@ -27,8 +27,9 @@ const NUMBER_KEYS: [char; 10] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0 impl LinksState { pub fn new(content: &str) -> Self { let links = LinkFinder::new() + .url_must_have_scheme(false) + .kinds(&[LinkKind::Url]) .links(content) - .filter(|l| *l.kind() == LinkKind::Url) .map(|l| l.as_str().to_string()) .collect(); @@ -76,11 +77,16 @@ impl LinksState { fn open_link_by_id(&self, id: usize) -> EventResult { if let Some(link) = self.links.get(id) { - if let Err(error) = open::that(link) { - return EventResult::ErrorOpeningLink { - link: link.to_string(), - error, - }; + // The `http://` or `https://` schema is necessary for open::that to + // successfully open the link in the browser. + let link = if link.starts_with("http://") || link.starts_with("https://") { + link.clone() + } else { + format!("https://{link}") + }; + + if let Err(error) = open::that(&link) { + return EventResult::ErrorOpeningLink { link, error }; } } EventResult::Handled