From 775236303904fcaa6097e524eef221e4c6c73b45 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 13 Dec 2024 15:47:21 +0100 Subject: [PATCH] exclude external links: update list (fix #91) --- src/utils/markdown.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/utils/markdown.rs b/src/utils/markdown.rs index 511afda..e051a12 100644 --- a/src/utils/markdown.rs +++ b/src/utils/markdown.rs @@ -68,7 +68,37 @@ pub fn get_options(path: Option, metadata_type: MType) -> ComrakOption .underline(true) .maybe_link_url_rewriter(match metadata_type { MType::Cours => Some(Arc::new(move |url: &str| { - if url.contains("://") { + // Exclude external links + if [ + "://", + "mailto:", + "magnet:", + "ftp:", + "tel:", + "irc:", + "geo:", + "ftps:", + "im:", + "ircs:", + "bitcoin:", + "matrix:", + "mms:", + "news:", + "nntp:", + "openpgp4fpr:", + "sftp:", + "sip:", + "sms:", + "smsto:", + "ssh:", + "urn:", + "webcal:", + "wtai:", + "xmpp:", + ] + .iter() + .any(|&item| url.contains(item)) + { return String::from(url); }