From 67fcd65bcce196258bfaefeb2b36a1a226ce0ce5 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 25 May 2024 16:19:35 -0400 Subject: [PATCH] fix tiktok user parsing --- .../markdown/src/markdown_with_socials_to_html.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/lib/markdown/src/markdown_with_socials_to_html.rs b/crates/lib/markdown/src/markdown_with_socials_to_html.rs index 4ba16630b1..c2c7f8962a 100644 --- a/crates/lib/markdown/src/markdown_with_socials_to_html.rs +++ b/crates/lib/markdown/src/markdown_with_socials_to_html.rs @@ -70,7 +70,7 @@ fn replace_reddit_user(input: &str) -> Cow { } static TIKTOK_USER: Lazy = 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 { @@ -197,6 +197,12 @@ mod tests { "

tiktok/@storyteller_ai

\n"); } + #[test] + pub fn tiktok_user_with_dot() { + assert_eq!(&markdown_with_socials_to_html("tiktok/@foo.bar"), + "

tiktok/@foo.bar

\n"); + } + #[test] pub fn tiktok_dot_com() { assert_eq!(&markdown_with_socials_to_html("tiktok.com/@storyteller_ai"), @@ -219,6 +225,12 @@ mod tests { "

tiktok/storyteller_ai

\n"); } + #[test] + pub fn tiktok_user_with_dot() { + assert_eq!(&markdown_with_socials_to_html("tiktok/foo.bar"), + "

tiktok/foo.bar

\n"); + } + #[test] pub fn tiktok_dot_com() { assert_eq!(&markdown_with_socials_to_html("tiktok.com/storyteller_ai"),