diff --git a/spec.md b/spec.md
index e1b3d6a..be57dad 100644
--- a/spec.md
+++ b/spec.md
@@ -38,7 +38,7 @@ Make email addresses clickable, opens the chat with that contact and creates it
#### Format
- format should follow standards (as time of writing the current implementation is still fairly dumb)
-- trailing `.` is not part of the email address and should not be parsed with it.
+- `.`-s are a part of the email address, but trailing ones are removed.
diff --git a/src/parser/parse_from_text/mod.rs b/src/parser/parse_from_text/mod.rs
index 3710fc4..819679e 100644
--- a/src/parser/parse_from_text/mod.rs
+++ b/src/parser/parse_from_text/mod.rs
@@ -100,7 +100,7 @@ pub(crate) fn extract_mention_addresses(input: &str) -> Vec {
break;
}
}
- result.sort();
+ result.sort_unstable();
result.dedup();
result
}
diff --git a/tests/text_to_ast/text_only.rs b/tests/text_to_ast/text_only.rs
index 4d6a8ba..4ac7a68 100644
--- a/tests/text_to_ast/text_only.rs
+++ b/tests/text_to_ast/text_only.rs
@@ -302,56 +302,18 @@ fn mention_do_not_parse_last_dot() {
#[test]
fn mention_do_not_parse_last_char_if_special() {
- assert_eq!(
- parse_only_text("you can ping me via @me@provider.tld!"),
- vec![
- Text("you can ping me via "),
- Mention {
- address: "me@provider.tld"
- },
- Text("!")
- ]
- );
- assert_eq!(
- parse_only_text("you can ping me via @me@provider.tld?"),
- vec![
- Text("you can ping me via "),
- Mention {
- address: "me@provider.tld"
- },
- Text("?")
- ]
- );
- assert_eq!(
- parse_only_text("you can ping me via @me@provider.tld,"),
- vec![
- Text("you can ping me via "),
- Mention {
- address: "me@provider.tld"
- },
- Text(",")
- ]
- );
- assert_eq!(
- parse_only_text("you can ping me via @me@provider.tld:"),
- vec![
- Text("you can ping me via "),
- Mention {
- address: "me@provider.tld"
- },
- Text(":")
- ]
- );
- assert_eq!(
- parse_only_text("you can ping me via @me@provider.tld;"),
- vec![
- Text("you can ping me via "),
- Mention {
- address: "me@provider.tld"
- },
- Text(";")
- ]
- );
+ for c in ["!", "?", ",", ":", ";"] {
+ assert_eq!(
+ parse_only_text(&("you can ping me via @me@provider.tld".to_string() + c)),
+ vec![
+ Text("you can ping me via "),
+ Mention {
+ address: "me@provider.tld"
+ },
+ Text(c)
+ ]
+ );
+ }
}
#[test]