Possible fix for #169
This commit is contained in:
@@ -39,7 +39,7 @@ module Typhoeus
|
||||
#
|
||||
# @return [ Boolean ]
|
||||
def has_valid_hash?(error_404_hash, homepage_hash)
|
||||
body_hash = Digest::MD5.hexdigest(self.body)
|
||||
body_hash = WebSite.page_hash(self)
|
||||
|
||||
body_hash != error_404_hash && body_hash != homepage_hash
|
||||
end
|
||||
|
||||
@@ -76,9 +76,16 @@ class WebSite
|
||||
redirection
|
||||
end
|
||||
|
||||
# Return the MD5 hash of the page given by url
|
||||
def self.page_hash(url)
|
||||
Digest::MD5.hexdigest(Browser.get(url).body)
|
||||
# Compute the MD5 of the page
|
||||
# Comments are deleted from the page to avoid cache generation details
|
||||
#
|
||||
# @param [ String, Typhoeus::Response ] page The url of the response of the page
|
||||
#
|
||||
# @return [ String ] The MD5 hash of the page
|
||||
def self.page_hash(page)
|
||||
page = Browser.get(page) unless page.is_a?(Typhoeus::Response)
|
||||
|
||||
Digest::MD5.hexdigest(page.body.gsub(/<!--[^>]+-->/, ''))
|
||||
end
|
||||
|
||||
def homepage_hash
|
||||
|
||||
Reference in New Issue
Block a user