FIX: Do not check for duplicate links in Onebox (#13345)

If a user posted a URL that appeared inside a Onebox, then the user
got a duplicate link notice. This was fixed by skipping those links in
Ruby.

If a user posted a URL that was Oneboxes and contained other links that
appeared in previous posts, then the user got a duplicate link notice.
This was fixed by skipping those links in JavaScript.
This commit is contained in:
Bianca Nenciu
2021-06-18 18:55:24 +03:00
committed by GitHub
parent 74f7295631
commit 1e992d9193
3 changed files with 30 additions and 3 deletions

View File

@ -324,8 +324,11 @@ module PrettyText
links = []
doc = Nokogiri::HTML5.fragment(html)
# remove href inside quotes & elided part
doc.css("aside.quote a, .elided a").each { |a| a["href"] = "" }
# extract onebox links
doc.css("aside.onebox[data-onebox-src]").each { |onebox| links << DetectedLink.new(onebox["data-onebox-src"], false) }
# remove href inside quotes & oneboxes & elided part
doc.css("aside.quote a, aside.onebox a, .elided a").remove
# extract all links
doc.css("a").each do |a|