Skip to content

Commit

Permalink
Treat meta[property] as a space-separated list (mastodon#10604)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
da2x authored and hiyuki2578 committed Oct 2, 2019
1 parent d039501 commit 14391a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/fetch_link_card_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def attempt_opengraph
end

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

def lock_options
Expand Down

0 comments on commit 14391a5

Please sign in to comment.