Zensavona / domainatrex

:smiling_imp: A library for parsing TLDs from urls in Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

:wave: Question about TLDs

aerosol opened this issue Β· comments

commented

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 :)

commented

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.

commented

I meant, it would've been potentially more useful to retrieve {:ok, %{domain: "foo", subdomain: "", tld: "app", public_suffix: "netlify.app"}} or similar.