Skip to content

Commit

Permalink
Merge pull request #25 from fabiokr/bugfix-tld-updates
Browse files Browse the repository at this point in the history
Bugfix tld updates
  • Loading branch information
Zensavona authored Oct 25, 2023
2 parents 9ee0b7d + 4c30d4e commit 309e8c3
Show file tree
Hide file tree
Showing 6 changed files with 3,364 additions and 1,933 deletions.
5 changes: 2 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
elixir 1.14.2-otp-25
erlang 25.1.2
nodejs 16.14.2
erlang 26.1.1
elixir 1.15.6-otp-26
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add the following to your `mix.exs`
```
defp deps do
[{:domainatrex, "~> 3.0.2"}]
[{:domainatrex, "~> 3.0.3"}]
```

Expand All @@ -36,7 +36,7 @@ iex> Domainatrex.parse("blog.someone.id.au")

For maximum performance, `Domainatrex` reads the list of all known top-level domains at compile time.
Likewise, by default, the package will attempt to fetch the latest list of TLDs from the web before
falling back to a local (potentially out of date) copy. You can configure this behavior in your
falling back to a local (potentially out of date) copy. You can configure this behavior in your
`config.exs` as follows:

- `:fetch_latest`: A Boolean flag to determine whether `Domainatrex` should try to fetch the latest
Expand All @@ -61,14 +61,15 @@ config :domainatrex,

## Changelog


### 3.0.3
- Fix issue with new, longer domains from public_suffix_list.dat
### 3.0.1
- Resolve warnings about SSL and `Mix.Config` being deprecated.
### 3.0.0
- Breaking change: default to including private domains. `:include_private == false` is still respected (but defaults to false), and a new env var `:icann_only` is added and defaults to false.
### 2.4.0
- Support disabling compile time http request with `:fetch_latest` config (thanks @s3cur3 for the PR!)
### 2.3.0
### 2.3.0
- Bump deps
### 2.2.0
- Use `Logger` for logging
Expand Down
37 changes: 37 additions & 0 deletions lib/domainatrex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ defmodule Domainatrex do
defp match([unquote(Enum.at(suffix, 0)), unquote(Enum.at(suffix, 1)) | _] = args) do
format_response(Enum.slice(args, 0, 5), Enum.slice(args, 5, 10))
end

6 ->
defp match([unquote(Enum.at(suffix, 0)), unquote(Enum.at(suffix, 1)), a]) do
format_response([unquote(Enum.at(suffix, 0)), unquote(Enum.at(suffix, 1))], [a])
end

defp match([unquote(Enum.at(suffix, 0)), unquote(Enum.at(suffix, 1)), a, b]) do
format_response([unquote(Enum.at(suffix, 0)), unquote(Enum.at(suffix, 1))], [a, b])
end

defp match([unquote(Enum.at(suffix, 0)), unquote(Enum.at(suffix, 1)) | _] = args) do
format_response(Enum.slice(args, 0, 6), Enum.slice(args, 6, 10))
end
end
else
case length(suffix) do
Expand Down Expand Up @@ -183,6 +196,30 @@ defmodule Domainatrex do
)
end

6 ->
defp match(
[
unquote(Enum.at(suffix, 0)),
unquote(Enum.at(suffix, 1)),
unquote(Enum.at(suffix, 2)),
unquote(Enum.at(suffix, 3)),
unquote(Enum.at(suffix, 4)),
unquote(Enum.at(suffix, 5)) | tail
] = args
) do
format_response(
[
Enum.at(args, 0),
Enum.at(args, 1),
Enum.at(args, 2),
Enum.at(args, 3),
Enum.at(args, 4),
Enum.at(args, 5)
],
tail
)
end

_ ->
{:error, "There exists a domain in the list which contains more than 5 dots: #{suffix}"}
end
Expand Down
Loading

0 comments on commit 309e8c3

Please sign in to comment.