lib/link_checker.rb in link-checker-0.1.2 vs lib/link_checker.rb in link-checker-0.2.0

- old
+ new

@@ -17,11 +17,14 @@ }.reject{|path| path.nil?} end def self.find_external_links(file_path) Nokogiri::HTML(open(file_path)).css('a'). - select{|link| link.attribute('href').value =~ /^https?\:\/\// } + select do |link| + !link.attribute('href').nil? && + link.attribute('href').value =~ /^https?\:\/\// + end end def self.check_link(uri, redirected=false) uri = URI.parse(uri) http = Net::HTTP.new(uri.host, uri.port) @@ -47,10 +50,9 @@ def check_links find_html_files.each do |file| bad_checks = [] warnings = [] - self.class.find_external_links(file).each do |link| uri = link.attribute('href').value begin response = self.class.check_link(uri) if response.class.eql? Redirect \ No newline at end of file