# Domainatrex
### Domainatrex is a TLD parsing library for Elixir, using the Public Suffix list.
[](https://travis-ci.org/Zensavona/domainatrex) [](http://inch-ci.org/github/zensavona/domainatrex) [](https://coveralls.io/github/Zensavona/domainatrex?branch=master) [](https://beta.hexfaktor.org/github/Zensavona/domainatrex) [](https://hex.pm/packages/domainatrex) [](https://hex.pm/packages/domainatrex) [](http://opensource.org/licenses/MIT)
### [Read the docs](https://hexdocs.pm/domainatrex)
## Installation
Add the following to your `mix.exs`
```
defp deps do
[{:domainatrex, "~> 2.3.0"}]
```
## Usage
`Domainatrex` should be able to handle all valid hostnames, it uses the [Public Suffix List](https://publicsuffix.org/list/) and is heavily inspired by the fantastic [Domainatrix](https://github.com/pauldix/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"}}
```
## Changelog
### 2.3.0
- Handle wildcard domains (thanks @yknx4 for the PR)
- Public suffix list custom URL and fallback file custom path (thanks @daareiza for the PR)
### 2.2.0
- Use `Logger` for logging
### 2.1.4
- Pin a version of `nimble_parsec` to fix a compilation error on `makeup` (`makeup` has fixed this downstream, so when `ex_doc` updates `makeup`, this will no longer be required)
### 2.1.3
- Merge a couple of minor PRs
### 2.1.2
- Improve tests and docs slightly
### 2.1.1
- Privatise `Domainatrex.match/n` and `Domainatrex.format_response/2` as they are only ever intended for internal use
### 2.1.0
- 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.
### 2.0.0
- 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.
### 1.0.1
- Fully update the tests to reflect changes in `2.0.0` (thanks for the PR @pbonney!)