Skip to content

Commit

Permalink
add intercept_redirect? method to match style of other comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
knzconnor authored and Luke Melia committed May 31, 2010
1 parent 3c5fdd7 commit f563174
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/rack/bug/toolbar.rb
Expand Up @@ -19,12 +19,8 @@ def call(env)

@response = Rack::Response.new(body, status, headers)

if @response.redirect? && @env["rack-bug.intercept_redirects"]
intercept_redirect
end
if modify?
inject_toolbar
end
intercept_redirect if intercept_redirect?
inject_toolbar if modify?

return @response.to_a
end
Expand All @@ -37,6 +33,10 @@ def intercept_redirect
@response = new_response
end

def intercept_redirect?
@response.redirect? && @env["rack-bug.intercept_redirects"]
end

def modify?
@response.ok? &&
@env["HTTP_X_REQUESTED_WITH"] != "XMLHttpRequest" &&
Expand Down

0 comments on commit f563174

Please sign in to comment.