Commit 74e6cbdca6
Unregistered key
Layout: unified · split
src/windows/room/chat.rs +8 −1
| @@ -1384,7 +1384,7 @@ fn extract_mentions(content: &TextMessageEventContent) -> Mentions { | ||
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | 1386 | fn extract_mentions_str(html: &str) -> Mentions { |
| 1387 | let re = Regex::new(r#"<a href="(https://matrix.to/#/@[^"]*:[^"]*)">"#).unwrap(); | |
| 1387 | let re = Regex::new(r#"<a href="(https://matrix.to/#/@[^"]*:[^"]*)"[^>]*>"#).unwrap(); | |
| 1388 | 1388 | |
| 1389 | 1389 | let user_ids = re.captures_iter(html).filter_map(|capture| { |
| 1390 | 1390 | let link = capture.get(1)?.as_str(); |
| @@ -1526,6 +1526,13 @@ mod tests { | ||
| 1526 | 1526 | assert_eq!(res, vec!["@user:example.com"]); |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | #[test] | |
| 1530 | fn test_extract_mentions_title() { | |
| 1531 | let twim = r#"<a href="https://matrix.to/#/@this-week-in:matrix.org" title="@this-week-in:matrix.org">TWIM</a>"#; | |
| 1532 | let res = mentions_in(twim); | |
| 1533 | assert_eq!(res, vec!["@this-week-in:matrix.org"]); | |
| 1534 | } | |
| 1535 | ||
| 1529 | 1536 | #[test] |
| 1530 | 1537 | fn test_extract_mentions_multiple_dedupe() { |
| 1531 | 1538 | let res = mentions_in( |