提交 b8d7bcf9 编写于 作者: R Rafael França 提交者: GitHub

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

Fix ActionView::Helpers#current_page? with trailing space issue.
......@@ -548,6 +548,8 @@ def current_page?(options)
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
......
......@@ -503,6 +503,12 @@ def test_current_page_with_double_escaped_params
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("/")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册