Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Fix no link previews being generated for pages with invalid structure…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored Nov 13, 2021
1 parent 070b1b8 commit 5d7c852
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/lib/link_details_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def first_of_value(arr)
end

def json
@json ||= Oj.load(@data)
@json ||= first_of_value(Oj.load(@data))
end
end

Expand Down Expand Up @@ -178,6 +178,8 @@ def structured_data
@structured_data ||= begin
json_ld = document.xpath('//script[@type="application/ld+json"]').map(&:content).first
json_ld.present? ? StructuredData.new(json_ld) : nil
rescue Oj::ParseError
nil
end
end

Expand Down

0 comments on commit 5d7c852

Please sign in to comment.