diff --git a/src/parser/parse_from_text/mod.rs b/src/parser/parse_from_text/mod.rs index 4b3d29a..3710fc4 100644 --- a/src/parser/parse_from_text/mod.rs +++ b/src/parser/parse_from_text/mod.rs @@ -91,9 +91,12 @@ pub(crate) fn extract_mention_addresses(input: &str) -> Vec { if let Ok((rest, Element::Mention { address })) = text_elements::mention(remaining) { result.push(address.to_owned()); remaining = rest; - } else if let Ok((_, rest)) = take_until::<&str, &str, CustomError<&str>>("@")(remaining) { + continue; + } + if let Ok((rest, _)) = take_until::<&str, &str, CustomError<&str>>(" @")(remaining) { remaining = rest; } else { + // there is no mention anymore in this message break; } } diff --git a/tests/mentions.rs b/tests/mentions.rs index 6e2a6e1..a410129 100644 --- a/tests/mentions.rs +++ b/tests/mentions.rs @@ -5,7 +5,7 @@ fn extract_mentions() { let mention_text = "Ping @email@address.tld and @email1@address.tld!"; assert_eq!( extract_mention_addresses(mention_text), - vec!["email@address.tld", "email1@address.tld"] + vec!["email1@address.tld", "email@address.tld"] ) } @@ -15,11 +15,7 @@ fn extract_mentions_are_deduped_and_sorted() { "Ping @email@address.tld, @abc@example.com, @abc@example.com and @email1@address.tld!\n@email1@address.tld your opinion would be especially helpful."; assert_eq!( extract_mention_addresses(mention_text), - vec![ - "@abc@example.com", - "email@address.tld", - "email1@address.tld" - ] + vec!["abc@example.com", "email1@address.tld", "email@address.tld"] ) }