From fa619b051b5e12c6b1e8b91a32d6738edafcc3af Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 12 Jan 2007 07:02:38 +0000 Subject: link_to_unless_current works with full URLs as well as paths. Closes #6891. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5896 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/url_helper.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/helpers/url_helper.rb') diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 21b5e9075c..6a66585387 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -310,9 +310,15 @@ module ActionView end end - # Returns true if the current page uri is generated by the +options+ passed. + # True if the current request uri was generated by the given +options+. def current_page?(options) - CGI.escapeHTML(self.url_for(options)) == @controller.request.request_uri + url_string = CGI.escapeHTML(url_for(options)) + request = @controller.request + if url_string =~ /^\w+:\/\// + url_string == "#{request.protocol}#{request.host_with_port}#{request.request_uri}" + else + url_string == request.request_uri + end end private -- cgit v1.2.3