:wave: Question about TLDs
aerosol opened this issue Β· comments
Hi π, just wondering why parsing "foo.netlify.app" returns "netlify.app" TLD and "foo" domain. That's not entirely accurate, is it?
iex(2)> Domainatrex.parse("foo.netlify.app")
{:ok, %{domain: "foo", subdomain: "", tld: "netlify.app"}}
Hi, netlify.app
is a valid TLD - please see the public suffix list (search "netlify" on that page, you'll find it).
In recent times many companies who host things on what we would think of as subdomains register their own "private" TLD extensions like this (e.g. blogspot.com
). If you want to ignore these and parse them in an intuitive but incorrect way, you can add config :domainatrex, include_private: false
to your config file.
This config option is undocumented because it defaults to true
and you probably shouldn't change it unless you know what you're doing :)
Thanks for your response; I was misled by the wording used in the struct key, public suffix and TLD are not the same thing, I thought.
I meant, it would've been potentially more useful to retrieve {:ok, %{domain: "foo", subdomain: "", tld: "app", public_suffix: "netlify.app"}}
or similar.