Fix emoji hashtags
This commit is contained in:
@@ -132,7 +132,7 @@ impl NewPost {
|
|||||||
for word in content.split_whitespace() {
|
for word in content.split_whitespace() {
|
||||||
if word.starts_with('#') && word.len() > 1 {
|
if word.starts_with('#') && word.len() > 1 {
|
||||||
let tag = word[1..]
|
let tag = word[1..]
|
||||||
.trim_end_matches(|c: char| !c.is_alphanumeric())
|
.trim_end_matches(|c: char| c.is_ascii_punctuation())
|
||||||
.to_lowercase();
|
.to_lowercase();
|
||||||
if !tag.is_empty() {
|
if !tag.is_empty() {
|
||||||
hashtags.insert(tag);
|
hashtags.insert(tag);
|
||||||
@@ -155,9 +155,8 @@ mod tests {
|
|||||||
("No hashtags here", vec![]),
|
("No hashtags here", vec![]),
|
||||||
("#tag1 with #tag2!", vec!["tag1", "tag2"]),
|
("#tag1 with #tag2!", vec!["tag1", "tag2"]),
|
||||||
("Ignore # empty", vec![]),
|
("Ignore # empty", vec![]),
|
||||||
("Keep #alphanumeric123", vec!["alphanumeric123"]),
|
("Testing emoji #🍌banana", vec!["🍌banana"]),
|
||||||
("Testing emoji #🍌sfd", vec!["🍌sfd"]),
|
("Testing emoji #🍌", vec!["🍌"]),
|
||||||
("Testing emoji with space #🍌 sfd", vec!["🍌"]),
|
|
||||||
("Duplicate #tag #tag #tag", vec!["tag"]),
|
("Duplicate #tag #tag #tag", vec!["tag"]),
|
||||||
("Mixed case #TaG #tag #TAG", vec!["tag"]),
|
("Mixed case #TaG #tag #TAG", vec!["tag"]),
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user