Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Greshilov committed Oct 26, 2023
1 parent 778c823 commit 1ca285b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 52 deletions.
2 changes: 1 addition & 1 deletion spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<a name="mentions" id="mentions"></a>

Expand Down
2 changes: 1 addition & 1 deletion src/parser/parse_from_text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub(crate) fn extract_mention_addresses(input: &str) -> Vec<String> {
break;
}
}
result.sort();
result.sort_unstable();
result.dedup();
result
}
62 changes: 12 additions & 50 deletions tests/text_to_ast/text_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 @[email protected]!"),
vec![
Text("you can ping me via "),
Mention {
address: "[email protected]"
},
Text("!")
]
);
assert_eq!(
parse_only_text("you can ping me via @[email protected]?"),
vec![
Text("you can ping me via "),
Mention {
address: "[email protected]"
},
Text("?")
]
);
assert_eq!(
parse_only_text("you can ping me via @[email protected],"),
vec![
Text("you can ping me via "),
Mention {
address: "[email protected]"
},
Text(",")
]
);
assert_eq!(
parse_only_text("you can ping me via @[email protected]:"),
vec![
Text("you can ping me via "),
Mention {
address: "[email protected]"
},
Text(":")
]
);
assert_eq!(
parse_only_text("you can ping me via @[email protected];"),
vec![
Text("you can ping me via "),
Mention {
address: "[email protected]"
},
Text(";")
]
);
for c in ["!", "?", ",", ":", ";"] {
assert_eq!(
parse_only_text(&("you can ping me via @[email protected]".to_string() + c)),
vec![
Text("you can ping me via "),
Mention {
address: "[email protected]"
},
Text(c)
]
);
}
}

#[test]
Expand Down

0 comments on commit 1ca285b

Please sign in to comment.