1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #25520 from st0012/fix-current-page

Fix ActionView::Helpers#current_page? with trailing space issue.
This commit is contained in:
Rafael França 2016-07-20 02:18:32 -03:00 committed by GitHub
commit b8d7bcf93e
2 changed files with 8 additions and 0 deletions

View file

@ -548,6 +548,8 @@ module ActionView
request_uri = url_string.index("?") ? request.fullpath : request.path
request_uri = URI.parser.unescape(request_uri).force_encoding(Encoding::BINARY)
url_string.chomp!("/") if url_string.start_with?("/") && url_string != "/"
if url_string =~ /^\w+:\/\//
url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}"
else

View file

@ -503,6 +503,12 @@ class UrlHelperTest < ActiveSupport::TestCase
assert current_page?(controller: 'foo', action: 'category', category: 'administração', callback_url: 'http://example.com/foo')
end
def test_current_page_with_trailing_slash
@request = request_for_url("/posts")
assert current_page?("/posts/")
end
def test_link_unless_current
@request = request_for_url("/")