Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix tld updates #25

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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