### Parse domains and check TLDs with Domainatrex Source: https://github.com/zensavona/domainatrex/blob/master/README.md Shows how to parse host names into domain, subdomain, and TLD parts, and how to check if a string is a top-level domain. The examples include parsing 'someone.com' and 'blog.someone.id.au', and checking 'com' and 'someone.com'. ```elixir iex> Domainatrex.parse("someone.com") {:ok, %{domain: "someone", subdomain: "", tld: "com"}} iex> Domainatrex.parse("blog.someone.id.au") {:ok, %{domain: "someone", subdomain: "blog", tld: "id.au"}} iex> Domainatrex.tld?("com") true iex> Domainatrex.tld?("someone.com") false ``` -------------------------------- ### Configure Domainatrex in config.exs Source: https://github.com/zensavona/domainatrex/blob/master/README.md Customizes Domainatrex behavior in config.exs, including fetching the latest TLD list, setting a custom public suffix list URL, adding custom suffixes, and controlling private domain inclusion. The example shows all available configuration options with their defaults. ```elixir config :domainatrex, # Explicitly allow compile-time HTTP request to fetch the latest list of TLDs (default) fetch_latest: true, # Download the public suffix list from the official source public_suffix_list_url: ~c"https://publicsuffix.org/list/public_suffix_list.dat", fallback_local_copy: "priv/my_app_custom_suffix_list.dat", # Add custom suffix for com.be custom_suffixes: ["com.be"], # Include private domains (default) include_private: true ``` -------------------------------- ### Add Domainatrex dependency to mix.exs Source: https://github.com/zensavona/domainatrex/blob/master/README.md Adds the Domainatrex package to an Elixir project's dependencies. Use this in the deps function of mix.exs to install version ~> 3.2. ```elixir defp deps do [ {:domainatrex, "~> 3.2"}, ] end ``` -------------------------------- ### Build and Test Commands Source: https://github.com/zensavona/domainatrex/blob/master/AGENTS.md Commands to run tests, checks, and formatting for the Domainatrex project. Use `mix test` to run all tests, `mix check` to run all checks (formatter, docs, unused deps), and `mix format` to format the code. ```bash mix test # Run all tests mix check # Run all checks (formatter, docs, unused deps) mix format # Format code ``` -------------------------------- ### parse/1 Source: https://github.com/zensavona/domainatrex/blob/master/AGENTS.md Parses a domain name into its subdomain, domain, and TLD parts. Returns a map with the parsed components. ```APIDOC ## parse/1 ### Description Parses a domain name into subdomain, domain, and TLD parts using the Mozilla Public Suffix List. ### Function Signature `parse(domain)` ### Parameters - **domain** (string) - Required - The domain name to parse. ### Returns A map with keys `:subdomain`, `:domain`, and `:tld` containing the parsed parts. ### Example ```elixir Domainatrex.parse("www.example.co.uk") # => %{subdomain: "www", domain: "example", tld: "co.uk"} ``` ``` -------------------------------- ### tld?/1 Source: https://github.com/zensavona/domainatrex/blob/master/AGENTS.md Checks whether a given string is a valid top-level domain (TLD) according to the Public Suffix List. ```APIDOC ## tld?/1 ### Description Determines if the given string is a valid top-level domain (TLD) based on the Public Suffix List. ### Function Signature `tld?(domain)` ### Parameters - **domain** (string) - Required - The string to check as a TLD. ### Returns A boolean indicating whether the string is a valid TLD. ### Example ```elixir Domainatrex.tld?("co.uk") # => true ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.