From ba9f47bb57e900ae1c163759ee04e596d87c06bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 11 Oct 2020 14:15:49 +0200 Subject: [PATCH] fix crash on index error due to hyperlink at the end of the file --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 8d1e850..8601741 100644 --- a/src/main.rs +++ b/src/main.rs @@ -215,7 +215,7 @@ 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()) + (link.start() == 0 || link.end() == result.len() - 1) || (!start_delims.contains(&result_vec[link.start() - 1]) && !end_delims.contains(&result_vec[link.end() + 1])) });