lib/bullet/rack.rb in bullet-2.2.1 vs lib/bullet/rack.rb in bullet-2.3.0

- old
+ new

@@ -11,11 +11,11 @@ status, headers, response = @app.call(env) return [status, headers, response] if empty?(response) response_body = nil if Bullet.notification? - if status == 200 and !response.body.frozen? and check_html?(headers, response) + if status == 200 && !response.body.frozen? && html_request?(headers, response) response_body = response.body << Bullet.gather_inline_notifications headers['Content-Length'] = response_body.length.to_s end Bullet.perform_out_of_channel_notifications(env) end @@ -29,11 +29,14 @@ # response may be ["Not Found"], ["Move Permanently"], etc. (response.is_a?(Array) && response.size <= 1) || !response.body.is_a?(String) || response.body.empty? end - def check_html?(headers, response) - headers['Content-Type'] and headers['Content-Type'].include? 'text/html' and response.body =~ %r{<html.*</html>}m + def html_request?(headers, response) + headers['Content-Type'] && + headers['Content-Type'].include?('text/html') && + response.body.include?("<html>") && + response.body.include?("</html>") end def no_browser_cache(headers) headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" headers["Pragma"] = "no-cache"