diff options
author | Jamis Buck <jamis@37signals.com> | 2005-09-02 09:10:31 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-09-02 09:10:31 +0000 |
commit | 6c44d35268d66374c5e2f0337183d5255c499a3c (patch) | |
tree | 5f9ba8c8de57b55b21d7a4b29759e6eace997394 /actionpack/lib/action_controller/request.rb | |
parent | d54aea29fc46bbf222abc3774569d074354273b2 (diff) | |
download | rails-6c44d35268d66374c5e2f0337183d5255c499a3c.tar.gz rails-6c44d35268d66374c5e2f0337183d5255c499a3c.tar.bz2 rails-6c44d35268d66374c5e2f0337183d5255c499a3c.zip |
AbstractRequest#domain returns nil when host is an ip address #2012 [kevin.clark@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2098 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/request.rb')
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 2 |
1 files changed, 2 insertions, 0 deletions
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 |