Skip to content

Commit

Permalink
Fixed exception when accessing a site via IP address.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Sep 23, 2010
1 parent 9eb8b18 commit 61bc2b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/subdomain-fu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/subdomain_fu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 => "")
Expand Down

0 comments on commit 61bc2b8

Please sign in to comment.