lib/webmention/verification/verifiers/html_verifier.rb in webmention-verification-5.0.0 vs lib/webmention/verification/verifiers/html_verifier.rb in webmention-verification-6.0.0
- old
+ new
@@ -1,20 +1,22 @@
+# frozen_string_literal: true
+
module Webmention
module Verification
module Verifiers
- class HtmlVerifier < BaseVerifier
+ class HtmlVerifier < Verifier
@mime_types = ['text/html']
- Verifiers.register(self)
+ Client.register_verifier(self)
HTML_ATTRIBUTE_MAP = {
- cite: %w[blockquote del ins q],
- data: %w[object],
- href: %w[a area],
- poster: %w[video],
- src: %w[audio embed img source track video],
- srcset: %w[img source]
+ 'cite' => %w[blockquote del ins q],
+ 'data' => %w[object],
+ 'href' => %w[a area],
+ 'poster' => %w[video],
+ 'src' => %w[audio embed img source track video],
+ 'srcset' => %w[img source]
}.freeze
private
def doc
@@ -24,10 +26,10 @@
def parse_response_body
HTML_ATTRIBUTE_MAP.each_with_object([]) { |(*args), matches| matches << search_doc(*args) }.flatten
end
def search_doc(attribute, elements)
- regexp = attribute == :srcset ? srcset_attribute_regexp : target_regexp
+ regexp = attribute == 'srcset' ? srcset_attribute_regexp : target_regexp
doc.css(*elements.map { |element| "#{element}[#{attribute}]" }).find_all do |node|
node[attribute].match?(regexp)
end
end