URLs with IP address as host aren't valid
Opened this issue · 5 comments
dentarg commented
[7] pry(main)> Twingly::URL.parse("http://127.0.0.1:57029").valid?
=> false
I think they should be valid, they are perfectly valid URLs and I think we want to use URLs like that when we test in our projects... and if the project use twingly-url, it will reject our valid test URLs :-(
They are not valid because of our PublicSuffix demands:
[11] pry(main)> PublicSuffix.parse("http://127.0.0.1:57029")
PublicSuffix::DomainInvalid: `http://127.0.0.1:57029' is not a valid domain
from /Users/dentarg/.gem/ruby/2.2.3/gems/public_suffix-1.5.3/lib/public_suffix.rb:62:in `parse'
dentarg commented
In #90 we learned how to extend the PSL, I guess it should be possible to write a PublicSuffix rule that allow IP addresses. :-)
dentarg commented
Or, if we identify the input as an IP address, we could skip the PSL step in that case.
dentarg commented
https://github.com/knu/ruby-domain_name
host = DomainName("[::1]") # IP addresses like "192.168.1.1" and "::1" are also acceptable host.ipaddr? #=> true