Treat meta[property] as a space-separated list (#10604)

The @property attribute in HTML is a space-separated list of values.
This change normalizes whitespace and finds the desired value in
the list instead of requiring an exact single-value match.

More details:
https://www.ctrl.blog/entry/rdfa-socialmedia-metadata.html
pull/1002/head
Daniel Aleksandersen 2019-04-21 04:48:19 +02:00 committed by Eugen Rochko
parent 01b1c377b1
commit 10bdd912d6
1 changed files with 1 additions and 1 deletions

View File

@ -165,7 +165,7 @@ class FetchLinkCardService < BaseService
end end
def meta_property(page, property) def meta_property(page, property)
page.at_xpath("//meta[@property=\"#{property}\"]")&.attribute('content')&.value || page.at_xpath("//meta[@name=\"#{property}\"]")&.attribute('content')&.value page.at_xpath("//meta[contains(concat(' ', normalize-space(@property), ' '), ' #{property} ')]")&.attribute('content')&.value || page.at_xpath("//meta[@name=\"#{property}\"]")&.attribute('content')&.value
end end
def lock_options def lock_options