Class: HTMLProofer::Check::Favicon
- Inherits:
-
HTMLProofer::Check
- Object
- HTMLProofer::Check
- HTMLProofer::Check::Favicon
- Defined in:
- lib/html_proofer/check/favicon.rb
Instance Attribute Summary
Attributes inherited from HTMLProofer::Check
#external_urls, #failures, #internal_urls, #options
Instance Method Summary collapse
Methods inherited from HTMLProofer::Check
#add_failure, #add_to_external_urls, #add_to_internal_urls, #create_element, #initialize, #short_name, short_name, subchecks
Methods included from Utils
#blank?, #create_nokogiri, #pluralize
Constructor Details
This class inherits a constructor from HTMLProofer::Check
Instance Method Details
#run ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/html_proofer/check/favicon.rb', line 6 def run found = false @html.css("link").each do |node| @favicon = create_element(node) next if @favicon.ignore? break if (found = @favicon.node["rel"].split.last.eql?("icon")) end return if immediate_redirect? if found if @favicon.url.protocol_relative? add_failure( "favicon link #{@favicon.url} is a protocol-relative URL, use explicit https:// instead", element: @favicon, ) elsif @favicon.url.remote? add_to_external_urls(@favicon.url, @favicon.line) elsif !@favicon.url.exists? add_failure( "internal favicon #{@favicon.url.raw_attribute} does not exist", element: @favicon, ) end else add_failure("no favicon provided") end end |