From e1e780a31d56f3bf22f13afd92b7e1274bd4b531 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Tue, 16 Nov 2010 18:49:08 +0800 Subject: Brought the domain method in AD http url inline with subdomain where @@tld_length is used by default. Also set the default value of @@tld_length to 1. --- actionpack/lib/action_dispatch/http/url.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch/http/url.rb') diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 4da82f958a..9c9eed2c6d 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -2,6 +2,7 @@ module ActionDispatch module Http module URL mattr_accessor :tld_length + self.tld_length = 1 # Returns the complete URL used for this request. def url @@ -67,7 +68,7 @@ module ActionDispatch # Returns the \domain part of a \host, such as "rubyonrails.org" in "www.rubyonrails.org". You can specify # a different tld_length, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk". - def domain(tld_length = 1) + def domain(tld_length = @@tld_length) return nil unless named_host?(host) host.split('.').last(1 + tld_length).join('.') -- cgit v1.2.3