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

Crash when requesting URL with tld_size different than expected #11

Open
s01ipsist opened this issue May 10, 2010 · 2 comments
Open

Crash when requesting URL with tld_size different than expected #11

s01ipsist opened this issue May 10, 2010 · 2 comments

Comments

@s01ipsist
Copy link

With a tld_size=1, requesting a url with the host 'localhost' will crash rails url_helpers. This is probably an edge case but was unavoidable for me as Monit (old version) would only use 'localhost' as a host so this made monit monitoring impossible.

The offending code

def self.host_without_subdomain(host)
parts = host.split('.')
parts[-(SubdomainFu.tld_size+1)..-1].join(".")
end

could be replaced with

def self.host_without_subdomain(host)
parts = host.split('.')
host_without_sub = parts[-(SubdomainFu.tld_size+1)..-1]
host_without_sub.blank? ? host : host_without_sub.join(".")
end

@danielmorrison
Copy link
Contributor

I'm playing with the best way to fix this and will submit a patch soon.

@danielmorrison
Copy link
Contributor

I patched it in a fork: http://github.com/collectiveidea/subdomain-fu/commit/9eb8b18d98dd5c28b9bc72f96e2dc95ccb85984

Would love to see it merged in.

pboling pushed a commit to pboling/subdomain-fu that referenced this issue Jun 17, 2011
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

2 participants