domainatrix icon indicating copy to clipboard operation
domainatrix copied to clipboard

Blows up on .dev (for Pow web server)

Open coreyward opened this issue 13 years ago • 3 comments

Obviously this isn't a legitimate TLD, but it's in use thanks to the Pow rack server by 37 Signals. It might make sense to add support for it, or at least not throw an error when it is used with parse:

>> Domainatrix.parse('http://google.com/')
=> #<Domainatrix::Url:0x00000104a196b8 @scheme="http", @host="google.com", @url="http://google.com/", @public_suffix="com", @domain="google", @subdomain="", @path="/">
>> Domainatrix.parse('http://google.dev/')
NoMethodError: undefined method `has_key?' for nil:NilClass
  from [...]/whiny_nil.rb:48:in `method_missing'
  from [...]/domainatrix-0.0.10/lib/domainatrix/domain_parser.rb:59:in `block in parse_domains_from_host'
  from [...]/domain_parser.rb:54:in `each_index'
  from [...]/domain_parser.rb:54:in `parse_domains_from_host'
  from [...]/domain_parser.rb:40:in `parse'

coreyward avatar Apr 14 '11 16:04 coreyward

yeah, I think some additional error handling is probably best. If it sees something it can't parse, throw an exception for that. I don't think adding .dev is a good idea since it's not a legit tld.

pauldix avatar Apr 14 '11 16:04 pauldix

A way of adding custom TLDs would be appreciated, too…

# for example:
Domainatrix.recognize_tld '.dev'

Then I could easily configure my app to recognize it, without putting unofficial TLDs in the gem.

coreyward avatar Apr 14 '11 22:04 coreyward

You can do this:

Domainatrix::DOMAIN_PARSER.public_suffixes.merge!("dev"=>{}) unless Rails.env.production?

ayn avatar May 10 '11 20:05 ayn