server: only add "view on site" link if it's not in the html body

This commit is contained in:
Bill Thiede 2024-08-19 10:57:09 -07:00
parent a81a803cca
commit 9a078cd238

View File

@ -121,11 +121,11 @@ impl Transformer for InlineStyle {
struct AddOutlink(Option<url::Url>); struct AddOutlink(Option<url::Url>);
impl Transformer for AddOutlink { impl Transformer for AddOutlink {
fn should_run(&self, _: &str) -> bool { fn should_run(&self, html: &str) -> bool {
self.0 if let Some(link) = &self.0 {
.as_ref() return link.scheme().starts_with("http") && !html.contains(link.as_str());
.map(|l| l.scheme().starts_with("http")) }
.unwrap_or(false) false
} }
fn transform(&self, html: &str) -> Result<String, TransformError> { fn transform(&self, html: &str) -> Result<String, TransformError> {
if let Some(url) = &self.0 { if let Some(url) = &self.0 {