Skip to content

Commit

Permalink
Fixing url_rewriter when there is no host available (example: includi…
Browse files Browse the repository at this point in the history
…ng url_helpers in a model where a @request object is not available)
  • Loading branch information
joslynesser committed Oct 12, 2011
1 parent a0ed776 commit a6e9cac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/subdomain_fu/subdomain_fu.rb
Expand Up @@ -131,7 +131,7 @@ def self.override_only_path?
end

def self.needs_rewrite?(subdomain, host)
return false if host.count('.') < config.tld_size
return false unless host && host.count('.') >= config.tld_size
case subdomain
when nil
#rewrite when there is a preferred mirror set and there is no subdomain on the host
Expand Down
1 change: 1 addition & 0 deletions spec/subdomain_fu_spec.rb
Expand Up @@ -258,6 +258,7 @@
it { SubdomainFu.needs_rewrite?(false,"awesome.localhost").should be_true }
it { SubdomainFu.needs_rewrite?(false,"www.localhost").should be_false }
it { SubdomainFu.needs_rewrite?("www","awesome.localhost").should be_true }
it { SubdomainFu.needs_rewrite?(nil, nil).should be_false }

describe "when preferred_mirror is false" do
before do
Expand Down

0 comments on commit a6e9cac

Please sign in to comment.