From 2d92f9c35577123cf5c58aaafc3f377fbf30e90c Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 11 Aug 2024 13:58:24 +0200 Subject: [PATCH] fix: skip attachments with url == image --- upub/core/src/traits/normalize.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/upub/core/src/traits/normalize.rs b/upub/core/src/traits/normalize.rs index e275150..298b990 100644 --- a/upub/core/src/traits/normalize.rs +++ b/upub/core/src/traits/normalize.rs @@ -73,6 +73,7 @@ impl Normalizer for crate::Context { .await?; } + let obj_image = object_model.image.clone().unwrap_or_default(); for attachment in object.attachment().flat() { let attachment_model = match attachment { Node::Empty => continue, @@ -83,12 +84,14 @@ impl Normalizer for crate::Context { Node::Object(o) => { let mut model = AP::attachment_q(o.as_document()?, object_model.internal, None)?; if let Set(u) | Unchanged(u) = model.url { + if u == obj_image { continue }; model.url = Set(self.cloaked(&u)); } model }, Node::Link(l) => { let url = l.href().unwrap_or_default(); + if url == obj_image { continue }; let mut media_type = l.media_type().unwrap_or("link").to_string(); let mut document_type = apb::DocumentType::Page; if self.cfg().compat.fix_attachment_images_media_type