keep leading \s+url to skip the thumbnail_url match

This commit is contained in:
yggverse 2026-03-20 05:09:39 +02:00
parent 6d2fa64314
commit ccbaa64f19

View file

@ -260,7 +260,8 @@ fn main() -> Result<()> {
} }
fn pre_format(data: &str, uploads: &mut HashSet<PathBuf>) -> String { fn pre_format(data: &str, uploads: &mut HashSet<PathBuf>) -> String {
const R: &str = r#"(?s)<UPL-IMAGE-PREVIEW\s+alt="([^"]*)"\s+.*?url="([^"]*)"\s+[^>]*>[^<]*</UPL-IMAGE-PREVIEW>"#; // * keep leading `\s+url` to skip the `thumbnail_url` match
const R: &str = r#"(?s)<UPL-IMAGE-PREVIEW\s+alt="([^"]*)"\s+.*?\s+url="([^"]*)"\s+[^>]*>[^<]*</UPL-IMAGE-PREVIEW>"#;
html_escape::decode_html_entities(&strip_tags::strip_tags( html_escape::decode_html_entities(&strip_tags::strip_tags(
&Regex::new(R).unwrap().replace_all(data, |c: &Captures| { &Regex::new(R).unwrap().replace_all(data, |c: &Captures| {
let rel = c[2].trim_start_matches("/").trim_start_matches("d/"); let rel = c[2].trim_start_matches("/").trim_start_matches("d/");