diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 7ba42a3..cf73e32 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -513,12 +513,13 @@ module ActionView # current_page?(:controller => 'library', :action => 'checkout') # # => false def current_page?(options) - url_string = CGI.escapeHTML(url_for(options)) + url_string = url_for(options) request = @controller.request + request_uri = CGI.escapeHTML(request.request_uri) if url_string =~ /^\w+:\/\// - url_string == "#{request.protocol}#{request.host_with_port}#{request.request_uri}" + url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}" else - url_string == request.request_uri + url_string == request_uri end end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 3065d33..ddb0f17 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -252,6 +252,11 @@ class UrlHelperTest < ActionView::TestCase end def test_link_unless_current + @controller.request = RequestMock.new("http://www.example.com/weblog/show?edit=true&filter=x") + @controller.url = "http://www.example.com/weblog/show?edit=true&filter=x" + assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog", :edit => true, :filter => 'x' }) + assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show?edit=true&filter=x") + @controller.request = RequestMock.new("http://www.example.com/weblog/show") @controller.url = "http://www.example.com/weblog/show" assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" })