Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current_domain returns wrong domain #13

Open
alPacino opened this issue Aug 5, 2010 · 0 comments
Open

current_domain returns wrong domain #13

alPacino opened this issue Aug 5, 2010 · 0 comments

Comments

@alPacino
Copy link

alPacino commented Aug 5, 2010

Hi!

Helper current_domain returns wrong domain. Ex.:
We have 'sub.domain.com.local'. For this case we, of course, set TLD to 2. and expect that current_domain will return 'domain.com.local', but it returns 'com.local' instead.

The cause is here:

diff --git a/vendor/plugins/subdomain-fu/lib/subdomain-fu.rb b/vendor/plugins/subdomain-fu/lib/subdomain-fu.rb
index 7b4a9da..9c8d7d4 100644
--- a/vendor/plugins/subdomain-fu/lib/subdomain-fu.rb
+++ b/vendor/plugins/subdomain-fu/lib/subdomain-fu.rb
@@ -140,8 +140,10 @@ module SubdomainFu
   #Enables subdomain-fu to more completely replace DHH's account_location plugin
   def self.current_domain(request)
     domain = ""
-    domain << request.subdomains[1..-1].join(".") + "." if request.subdomains.length > 1
-    domain << request.domain + request.port_string
+    subdomains = request.subdomains(SubdomainFu.tld_size)
+    domain << subdomains[1..-1].join(".") + "." if subdomains.length > 1
+    domain << request.domain(SubdomainFu.tld_size) + request.port_string
+    domain
   end
 
   module Controller

Here you used request.subdomains and request.domain w/o TLD param. By default it is set to 1. So, if tld_size is set to 1 in development.rb, for instance, everything works fine. But for example mentioned below this doesn't work as expected. I've just defined TLD param for calling request.subdomains and request.domain.

P.S. SubdomainFu.tld_size = X doesn't work for me. I get

undefined method `tld_size=' for SubdomainFu:Module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant