Commit 74e6cbdca6

74e6cbdca6c745a2d93a0cdd1a8967256379e635

parent: 4f44e7b02d

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-25 01:43 UTC
committer: <noreply@github.com>

Extract mentions from anchors that include `title` attributes (#743)

Layout: unified · split

src/windows/room/chat.rs +8 −1
@@ -1384,7 +1384,7 @@ fn extract_mentions(content: &TextMessageEventContent) -> Mentions {
1384} 1384}
1385 1385
1386fn extract_mentions_str(html: &str) -> Mentions { 1386fn 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 let user_ids = re.captures_iter(html).filter_map(|capture| { 1389 let user_ids = re.captures_iter(html).filter_map(|capture| {
1390 let link = capture.get(1)?.as_str(); 1390 let link = capture.get(1)?.as_str();
@@ -1526,6 +1526,13 @@ mod tests {
1526 assert_eq!(res, vec!["@user:example.com"]); 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 #[test] 1536 #[test]
1530 fn test_extract_mentions_multiple_dedupe() { 1537 fn test_extract_mentions_multiple_dedupe() {
1531 let res = mentions_in( 1538 let res = mentions_in(