server: only add "view on site" link if it's not in the html body
This commit is contained in:
parent
a81a803cca
commit
9a078cd238
@ -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 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user