weppos / publicsuffix-ruby

Domain name parser for Ruby based on the Public Suffix List.
https://simonecarletti.com/code/publicsuffix
MIT License
620 stars 109 forks source link

Allow full URLs #55

Closed mhuggins closed 10 years ago

mhuggins commented 10 years ago

If I'm trying to parse a full URL, it seems strange that I need to use both PublicSuffix and URI. e.g.:

domain = PublicSuffix.parse(URI.parse('http://www.example.com/foo/bar?x=y').host).domain

It seems like it would be relatively easy for this gem's #parse method to automatically to a URI.parse(...).domain to fetch the domain behind the scenes, falling back on the default implementation if URI can't parse the string.

weppos commented 10 years ago

Parsing a domain, as well parsing an email, is a simple problem, with no simple solution. I decided to avoid entering that field because it will make my life as a maintainer very complicated. It starts with http, then it will be https, ftps, exceptions, etc. There are so many variants to the problem, enough to consider that task beyond the purpose of this library.

Last but not least, the PublicSuffix is not used to extract an hostname from an URL or an email. Therefore, it makes sense to me to keep the functionalities of this library as close as possible to the original purpose of the PSL.