Be more lenient with OEmbed detection and validation

This commit is contained in:
Effy Elden 2022-12-20 15:48:56 +11:00 committed by GitHub
parent c1de673060
commit a676230e46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,7 +28,7 @@ class FetchOEmbedService
page = Nokogiri::HTML(html) page = Nokogiri::HTML(html)
if @format.nil? || @format == :json if @format.nil? || @format == :json
@endpoint_url ||= page.at_xpath('//link[@type="application/json+oembed"]')&.attribute('href')&.value @endpoint_url ||= page.at_xpath('//link[@type="application/json+oembed"]|//link[@type="text/json+oembed"]')&.attribute('href')&.value
@format ||= :json if @endpoint_url @format ||= :json if @endpoint_url
end end
@ -100,7 +100,7 @@ class FetchOEmbedService
end end
def validate(oembed) def validate(oembed)
oembed if oembed[:version] == '1.0' && oembed[:type].present? oembed if oembed[:version].to_s == '1.0' && oembed[:type].present?
end end
def html def html