Zensavona / domainatrex

:smiling_imp: A library for parsing TLDs from urls in Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Domainatrex crashes on amazon aws links

axelson opened this issue · comments

I expect domainatrex to be able to parse amazon s3 links properly. So Domainatrex.parse("s3.amazonaws.com") should succeed. Instead it throws the following error:

 ** (MatchError) no match of right hand side value: []
 stacktrace:
   (domainatrex) lib/domainatrex.ex:55: Domainatrex.format_response/2
   (domainatrex) lib/domainatrex.ex:34: Domainatrex.match/1
   test/domainatrex_test.exs:19: (test)

Failing test case:

  test "s3" do
    domain = "s3.amazonaws.com"
    assert Domainatrex.parse(domain) == {:ok, %{domain: "amazon", subdomain: "s3", tld: "com"}}
  end

I think Domainatrex can probably ignore all private domains in the public suffix list. Although there may be a better solution.

Hi Jason! Thanks for the catch, I'll implement a fix shortly 👍

This is fixed in 2.1.0 (avail. on hex now), hope this helps you!

Thanks! Out of curiosity how did you fix this?

Sorry to bring resurrect this old issue, but I'm getting an error trying to parse similar URLs. Specifically paths that contain execute-api.[region].amazonaws.com

iex(1)> Domainatrex.parse("1234.execute-api.us-east-1.amazonaws.com")
{:error, "Cannot parse: invalid domain"}

# note the extra "s"
iex(2)> Domainatrex.parse("1234.execute-api.us-east-1.amazonawss.com")
{:ok, %{domain: "amazonawss", tld: "com", subdomain: "1234.execute-api.us-east-1"}}

This is on Domainatrex v3.0.3