Add the following to your mix.exs
defp deps do
[{:domainatrex, "~> 2.2.0"}]
Domainatrex
should be able to handle all valid hostnames, it uses the Public Suffix List and is heavily inspired by the fantastic Domainatrix library for Ruby
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"}}
- Use
Logger
for logging
- Pin a version of
nimble_parsec
to fix a compilation error onmakeup
(makeup
has fixed this downstream, so whenex_doc
updatesmakeup
, this will no longer be required)
- Merge a couple of minor PRs
- Improve tests and docs slightly
- Privatise
Domainatrex.match/n
andDomainatrex.format_response/2
as they are only ever intended for internal use
- Better handle private domains. Private domains like
*.s3.amazonaws.com
are technically classed as TLDs (to my understanding?), it doesn't make a lot of sense to parse them this way. - Fetch a new copy of the public suffix list from The Internet on compile, falling back to a (now updated!) local copy.
- Change the API from returning explicit results to {:ok, result} or {:error, result}. This is to be more uniform with other libraries I use and for better
with
usage. Sorry if this fucks up your day.
- Fully update the tests to reflect changes in
2.0.0
(thanks for the PR @pbonney!)