fix tiktok user parsing

This commit is contained in:
Brandon Thomas
2024-05-25 16:19:35 -04:00
parent 58d7476d30
commit 67fcd65bcc
@@ -70,7 +70,7 @@ fn replace_reddit_user(input: &str) -> Cow<str> {
}
static TIKTOK_USER: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"(tiktok(.com)?/@?([\w\-_]+))").expect("regex should compile")
Regex::new(r"(tiktok(.com)?/@?([\w\.\-_]+))").expect("regex should compile")
});
fn replace_tiktok_user(input: &str) -> Cow<str> {
@@ -197,6 +197,12 @@ mod tests {
"<p><a href=\"https://www.tiktok.com/@storyteller_ai\">tiktok/@storyteller_ai</a></p>\n");
}
#[test]
pub fn tiktok_user_with_dot() {
assert_eq!(&markdown_with_socials_to_html("tiktok/@foo.bar"),
"<p><a href=\"https://www.tiktok.com/@foo.bar\">tiktok/@foo.bar</a></p>\n");
}
#[test]
pub fn tiktok_dot_com() {
assert_eq!(&markdown_with_socials_to_html("tiktok.com/@storyteller_ai"),
@@ -219,6 +225,12 @@ mod tests {
"<p><a href=\"https://www.tiktok.com/@storyteller_ai\">tiktok/storyteller_ai</a></p>\n");
}
#[test]
pub fn tiktok_user_with_dot() {
assert_eq!(&markdown_with_socials_to_html("tiktok/foo.bar"),
"<p><a href=\"https://www.tiktok.com/@foo.bar\">tiktok/foo.bar</a></p>\n");
}
#[test]
pub fn tiktok_dot_com() {
assert_eq!(&markdown_with_socials_to_html("tiktok.com/storyteller_ai"),