From 50fad938dd8daa53aa1203a9cf4dbd66df44c301 Mon Sep 17 00:00:00 2001 From: Butter Cat Date: Wed, 22 May 2024 16:31:07 -0400 Subject: [PATCH] Fix infinite loop when replacing text that contains dollar signs --- src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index d1b84a3..a0cdbe8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -930,7 +930,7 @@ pub fn rewrite_urls(input_text: &str) -> String { } text1 = REDDIT_PREVIEW_REGEX - .replace(&text1, formatted_url) + .replace(&text1, "/preview/pre$2") .replace(&image_to_replace, &_image_replacement) .replace("

", "") .to_string() @@ -1190,6 +1190,6 @@ async fn test_fetching_ws() { fn test_rewriting_image_links() { let input = r#"

caption 1

"#; - let output = r#"

caption 1

"#; + let output = r#"

caption 1