lib/onebox/engine/standard_embed.rb in onebox-1.8.17 vs lib/onebox/engine/standard_embed.rb in onebox-1.8.18
- old
+ new
@@ -56,11 +56,12 @@
headers = { 'Cookie' => options[:cookie] } if options[:cookie]
response = (Onebox::Helpers.fetch_response(url, nil, nil, headers) rescue nil)
doc = Nokogiri::HTML(response)
- unless skip_canonical_link
+ ignore_canonical = doc.at('meta[property="og:ignore_canonical"]')
+ unless ignore_canonical && ignore_canonical['content'].to_s == 'true'
# prefer canonical link
canonical_link = doc.at('//link[@rel="canonical"]/@href')
if canonical_link && "#{URI(canonical_link).host}#{URI(canonical_link).path}" != "#{URI(url).host}#{URI(url).path}"
response = (Onebox::Helpers.fetch_response(canonical_link, nil, nil, headers) rescue nil)
doc = Nokogiri::HTML(response) if response
@@ -121,13 +122,9 @@
twitter[$1.tr('-:','_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
end
end
twitter
- end
-
- def skip_canonical_link
- WhitelistedGenericOnebox.probable_discourse(URI(url))
end
end
end
end