From 9a078cd2382416107d337b75080a58dd4c75a803 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Mon, 19 Aug 2024 10:57:09 -0700 Subject: [PATCH] server: only add "view on site" link if it's not in the html body --- server/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/lib.rs b/server/src/lib.rs index c184c91..9e84d05 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -121,11 +121,11 @@ impl Transformer for InlineStyle { struct AddOutlink(Option); impl Transformer for AddOutlink { - fn should_run(&self, _: &str) -> bool { - self.0 - .as_ref() - .map(|l| l.scheme().starts_with("http")) - .unwrap_or(false) + fn should_run(&self, html: &str) -> bool { + if let Some(link) = &self.0 { + return link.scheme().starts_with("http") && !html.contains(link.as_str()); + } + false } fn transform(&self, html: &str) -> Result { if let Some(url) = &self.0 {