From 5c11104f9f26441d12c9a1e66fb7cc176ba36ab5 Mon Sep 17 00:00:00 2001 From: Vinoth Kanan Date: Wed, 15 Nov 2017 17:36:48 +0530 Subject: [PATCH] FIX: Duplicate a tag if image url is same to href --- lib/cooked_post_processor.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index c1aec48a37a..31ee7d0266a 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -110,13 +110,17 @@ class CookedPostProcessor parent = placeholder.parent parent.add_next_sibling(placeholder) - if parent.name == 'a' && parent["href"].present? && url != parent["href"] - parent["class"] = "link" - a.add_previous_sibling(parent) + if parent.name == 'a' && parent["href"].present? + if url == parent["href"] + parent.remove + else + parent["class"] = "link" + a.add_previous_sibling(parent) - lspan = create_span_node("url", parent["href"]) - parent.add_child(lspan) - lspan.add_previous_sibling(create_icon_node("link")) + lspan = create_span_node("url", parent["href"]) + parent.add_child(lspan) + lspan.add_previous_sibling(create_icon_node("link")) + end end end