Skip to content
Browse files

Allow for attributes in the html tag.

Obviously not the best way to test for this, but I didn't want to
involve a regexp or a dom parser. The old way didn't work for our app or
any app that puts attributes on html (like facebook open graph
attributes)
  • Loading branch information...
1 parent 3b4f466 commit a6e0a59593feeb586b29af85d9f56d9996fbd450 @aaronjensen aaronjensen committed
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/bullet/rack.rb
  2. +6 −0 spec/bullet/rack_spec.rb
View
2 lib/bullet/rack.rb
@@ -37,7 +37,7 @@ def file?(headers)
end
def html_request?(headers, response)
- headers['Content-Type'] && headers['Content-Type'].include?('text/html') && response.body.include?("<html>")
+ headers['Content-Type'] && headers['Content-Type'].include?('text/html') && response.body.include?("<html")
end
def no_browser_cache(headers)
View
6 spec/bullet/rack_spec.rb
@@ -22,6 +22,12 @@ module Bullet
middleware.should be_html_request(headers, response)
end
+ it "should be true if Content-Type is text/html and http body contains html tag with attributes" do
+ headers = {"Content-Type" => "text/html"}
+ response = stub(:body => "<html attr='hello'><head></head><body></body></html>")
+ middleware.should be_html_request(headers, response)
+ end
+
it "should be false if there is no Content-Type header" do
headers = {}
response = stub(:body => "<html><head></head><body></body></html>")

0 comments on commit a6e0a59

Please sign in to comment.
Something went wrong with that request. Please try again.