diff --git a/lib/subdomain-fu.rb b/lib/subdomain-fu.rb index 40ead12..848b7db 100644 --- a/lib/subdomain-fu.rb +++ b/lib/subdomain-fu.rb @@ -136,7 +136,7 @@ def self.current_subdomain(request) def self.current_domain(request) domain = "" domain << request.subdomains[1..-1].join(".") + "." if request.subdomains.length > 1 - domain << request.domain + request.port_string + domain << request.domain.to_s + request.port_string end module Controller diff --git a/spec/subdomain_fu_spec.rb b/spec/subdomain_fu_spec.rb index 5b1a246..3df42fe 100644 --- a/spec/subdomain_fu_spec.rb +++ b/spec/subdomain_fu_spec.rb @@ -175,6 +175,11 @@ request = mock("request", :subdomains => [], :domain => "", :port_string => "") SubdomainFu.current_domain(request).should == "" end + + it "should return an IP address if there is only an IP address" do + request = mock("request", :subdomains => [], :domain => "127.0.0.1", :port_string => "") + SubdomainFu.current_domain(request).should == "127.0.0.1" + end it "should return the current domain if there is only one level of subdomains" do request = mock("request", :subdomains => ["www"], :domain => "example.com", :port_string => "")