Change verify link service to use CSS selectors instead of a complex XPath query (#31815)

This commit is contained in:
Mike Dalessio authored and GitHub committed 2024-09-08 18:50:22 +00:00
1 parent 10143d053a
commit afa2e257e4
2 files changed
+24 -8

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ class VerifyLinkService < BaseService
def link_back_present?
return false if @body.blank?
links = Nokogiri::HTML5(@body).xpath('//a[contains(concat(" ", normalize-space(@rel), " "), " me ")]|//link[contains(concat(" ", normalize-space(@rel), " "), " me ")]')
links = Nokogiri::HTML5(@body).css("a[rel~='me'],link[rel~='me']")
if links.any? { |link| link['href']&.downcase == @link_back.downcase }
true