Ticket #4918: fix_current_page_patch.diff
| File fix_current_page_patch.diff, 1.9 kB (added by spideryoung, 9 months ago) |
|---|
-
test/template/url_helper_test.rb
old new 249 249 link_to_unless_current("Listing", "http://www.example.com/weblog/list") 250 250 end 251 251 252 def test_current_page? 253 @controller.request = RequestMock.new("/weblog/show?a=b&c=d&e=f", 'http://', 'www.example.com') 254 assert current_page?("/weblog/show?a=b&c=d&e=f") 255 assert current_page?("http://www.example.com/weblog/show?a=b&c=d&e=f") 256 assert !current_page?("/weblog/show?a=b&e=f") 257 assert !current_page?("http://www.example.com/weblog/show?a=b&x=y") 258 end 259 252 260 def test_mail_to 253 261 assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com") 254 262 assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson") -
lib/action_view/helpers/url_helper.rb
old new 433 433 # current_page?(:controller => 'library', :action => 'checkout') 434 434 # # => false 435 435 def current_page?(options) 436 url_string = CGI.escapeHTML(url_for(options))436 url_string = url_for(options) 437 437 request = @controller.request 438 request_uri = CGI.escapeHTML(request.request_uri) 438 439 if url_string =~ /^\w+:\/\// 439 url_string == "#{request.protocol}#{request.host_with_port}#{request .request_uri}"440 url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}" 440 441 else 441 url_string == request .request_uri442 url_string == request_uri 442 443 end 443 444 end 444 445