From 0c7efa315f1ed5be0ac853007090e279bbd3fbc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Mon, 12 Oct 2020 20:57:42 +0200 Subject: [PATCH] fix end link crashes once and for all! --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9682649..b4039fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -216,9 +216,10 @@ fn preprocess(string: String) -> String { let start_delims = vec![b'(', b'<']; let end_delims = vec![b')', b'>']; let links = finder.links(result.as_str()).filter(|link| { - (link.start() == 0 || link.end() == result.len() - 1) + // link.end() is the first char AFTER the link! + (link.start() == 0 || link.end() == result.len()) || (!start_delims.contains(&result_vec[link.start() - 1]) - && !end_delims.contains(&result_vec[link.end() + 1])) + && !end_delims.contains(&result_vec[link.end()])) }); let mut offset = 0;