Tld (TLD v0.1.1) View Source
Top-Level Domain module for BEAM.
Lets you get the current list of TLDs, as well as find the TLD in a domain name.
Link to this section Summary
Link to this section Functions
Get list of all Top-Level Domains.
Examples
iex> list = Tld.get_list()
iex> Enum.member?(list, "NET")
true
iex> Enum.member?(list, "TEST")
false
If input string contains a domain name, get its TLD.
Returns {:ok, "COM"} if found (COM being replaced with the actual TLD found), {:err, :not_found} if TLD was not found in string, and {:err, :invalid_input} if not given a string.
Examples
iex> Tld.get_tld_from_domain_name("contoso.com")
{:ok, "COM"}
iex> Tld.get_tld_from_domain_name("FACE.BORG.TEST")
{:err, :not_found}
iex> Tld.get_tld_from_domain_name("CORRUPT.GOV")
{:ok, "GOV"}
iex> Tld.get_tld_from_domain_name('NOTASTRING.NET')
{:err, :invalid_input}
iex> Tld.get_tld_from_domain_name(42)
{:err, :invalid_input}
iex> Tld.get_tld_from_domain_name(nil)
{:err, :invalid_input}