WebSite::page_hash Better comments detection
This commit is contained in:
@@ -85,7 +85,7 @@ class WebSite
|
|||||||
def self.page_hash(page)
|
def self.page_hash(page)
|
||||||
page = Browser.get(page) unless page.is_a?(Typhoeus::Response)
|
page = Browser.get(page) unless page.is_a?(Typhoeus::Response)
|
||||||
|
|
||||||
Digest::MD5.hexdigest(page.body.gsub(/<!--[^>]+-->/, ''))
|
Digest::MD5.hexdigest(page.body.gsub(/<!--.*?-->/m, ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
def homepage_hash
|
def homepage_hash
|
||||||
|
|||||||
@@ -193,7 +193,10 @@ describe 'WebSite' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when there are comments' do
|
context 'when there are comments' do
|
||||||
let(:page) { Typhoeus::Response.new(body: "yolo\n\n<!--I should no longer be there -->\nworld!") }
|
let(:page) {
|
||||||
|
body = "yolo\n\n<!--I should <script>no longer be</script> there -->\nworld!"
|
||||||
|
Typhoeus::Response.new(body: body)
|
||||||
|
}
|
||||||
|
|
||||||
it 'removes them' do
|
it 'removes them' do
|
||||||
@expected = "yolo\n\n\nworld!"
|
@expected = "yolo\n\n\nworld!"
|
||||||
|
|||||||
Reference in New Issue
Block a user