FIX: don't crash out searching for parent in oneboxer

This commit is contained in:
Sam 2015-09-22 12:42:13 +10:00
parent 9cad925c67
commit 18a8853181

View File

@ -82,13 +82,14 @@ module Oneboxer
changed = false
Oneboxer.each_onebox_link(doc) do |url, element|
onebox, preview = yield(url,element)
onebox, _preview = yield(url,element)
if onebox
parsed_onebox = Nokogiri::HTML::fragment(onebox)
next unless parsed_onebox.children.count > 0
# special logic to strip empty p elements
if element.parent &&
element.parent.node_name &&
element.parent.node_name.downcase == "p" &&
element.parent.children.count == 1
element = element.parent