Commit ed2280c477

ed2280c477c35fee57d7f58fc86b2e4fba02df3e

parent: 81870d8fa0

Unregistered key

vaw <git@nlih.de> · 2026-07-24 15:06 UTC
committer: <noreply@github.com>

Search plaintext body for links to open as fallback (#573)

Layout: unified · split

src/windows/room/chat.rs +8 −4
@@ -231,17 +231,21 @@ impl ChatState {
231 return Err(IambError::NoAttachment.into()); 231 return Err(IambError::NoAttachment.into());
232 } 232 }
233 233
234 let links = if let Some(html) = &msg.html { 234 let mut links = if let Some(html) = &msg.html {
235 html.get_links() 235 html.get_links()
236 } else { 236 } else {
237 linkify::LinkFinder::new() 237 vec![]
238 };
239
240 if links.is_empty() {
241 links = linkify::LinkFinder::new()
238 .links(&msg.event.body()) 242 .links(&msg.event.body())
239 .filter_map(|u| Url::parse(u.as_str()).ok()) 243 .filter_map(|u| Url::parse(u.as_str()).ok())
240 .scan(TreeGenState { link_num: 0 }, |state, u| { 244 .scan(TreeGenState { link_num: 0 }, |state, u| {
241 state.next_link_char().map(|c| (c, u)) 245 state.next_link_char().map(|c| (c, u))
242 }) 246 })
243 .collect() 247 .collect();
244 }; 248 }
245 249
246 if links.is_empty() { 250 if links.is_empty() {
247 return Err(IambError::NoAttachment.into()); 251 return Err(IambError::NoAttachment.into());