Skip to content

Commit

Permalink
current_subdomain is now returning subdomains without mirrors
Browse files Browse the repository at this point in the history
  • Loading branch information
asok committed Mar 30, 2011
1 parent 3515962 commit 9441765
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
= Changes in this fork

[current_subdomain] will return all subdomains except for mirrors.
For the URL http://www.stuff.example.com it will return "stuff" if "www" is configured as a mirror

= SubdomainFu

SubdomainFu provides a modern implementation of subdomain handling in Rails.
Expand Down
2 changes: 1 addition & 1 deletion lib/subdomain_fu/subdomain_fu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def self.needs_rewrite?(subdomain, host)
end

def self.current_subdomain(request)
subdomain = request.subdomains(SubdomainFu.config.tld_size).join(".")
subdomain = (request.subdomains(SubdomainFu.config.tld_size) - config.mirrors).join(".")
if has_subdomain?(subdomain)
subdomain
else
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 @@ -159,6 +159,11 @@
SubdomainFu.current_subdomain(request).should be_nil
end

it "should return current subdomain without a mirror" do
request = mock("request", :subdomains => ["www", "stuff"])
SubdomainFu.current_subdomain(request).should == "stuff"
end

it "should return the whole thing (including a .) if there's multiple subdomains" do
request = mock("request", :subdomains => ["awesome","rad"])
SubdomainFu.current_subdomain(request).should == "awesome.rad"
Expand Down

0 comments on commit 9441765

Please sign in to comment.