diff options
| -rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
| -rwxr-xr-x | actionpack/lib/action_controller/request.rb | 2 | ||||
| -rw-r--r-- | actionpack/test/controller/request_test.rb | 3 | 
3 files changed, 7 insertions, 0 deletions
| diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index c77c4d3329..db3ad9662b 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@  *SVN* +* AbstractRequest#domain returns nil when host is an ip address #2012 [kevin.clark@gmail.com] +  * ActionController documentation update #2051 [fbeausoleil@ftml.net]  * Yield @content_for_ variables to templates #2058 [Sam Stephenson] diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 3a29834b42..ca8dfff161 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -109,6 +109,8 @@ module ActionController      # Returns the domain part of a host, such as rubyonrails.org in "www.rubyonrails.org". You can specify      # a different <tt>tld_length</tt>, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk".      def domain(tld_length = 1) +      return nil if !/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.match(host).nil? +                host.split('.').last(1 + tld_length).join('.')      end diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 8b079df5dd..5bb5bc3469 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -44,6 +44,9 @@ class RequestTest < Test::Unit::TestCase      @request.host = "www.rubyonrails.co.uk"      assert_equal "rubyonrails.co.uk", @request.domain(2) +     +    @request.host = "192.168.1.200" +    assert_nil @request.domain    end    def test_subdomains | 
