Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make current_url? work with a HEAD method

ActionDispatch::Head was removed in favor of Rack::Head. But Rack::Head
does not convert GET requests to HEAD requests so we need to do
checking for HEAD requests ourselves.
  • Loading branch information...
commit f7277d99bf76e947fd404ac316eafeb993cc5bcd 1 parent c4bc360
@michiels michiels authored
View
2  actionpack/lib/action_view/helpers/url_helper.rb
@@ -514,7 +514,7 @@ def current_page?(options)
"in a #request method"
end
- return false unless request.get?
+ return false unless request.get? || request.head?
url_string = url_for(options)
View
6 actionpack/test/template/url_helper_test.rb
@@ -437,6 +437,12 @@ def request_for_url(url, opts = {})
ActionDispatch::Request.new(env)
end
+ def test_current_page_with_http_head_method
+ @request = request_for_url("/", :method => :head)
+ assert current_page?(url_hash)
+ assert current_page?("http://www.example.com/")
+ end
+
def test_current_page_with_simple_url
@request = request_for_url("/")
assert current_page?(url_hash)
Please sign in to comment.
Something went wrong with that request. Please try again.