Skip to content

😈 A library for parsing TLDs from urls in Elixir

Notifications You must be signed in to change notification settings

doofinder/domainatrex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Domainatrex

Domainatrex is a TLD parsing library for Elixir, using the Public Suffix list.

Build Status Inline docs Coverage Status Deps Status hex.pm version hex.pm downloads License

Installation

Add the following to your mix.exs


defp deps do
  [{:domainatrex, "~> 2.2.0"}]

Usage

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"}}

Changelog

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!)

About

😈 A library for parsing TLDs from urls in Elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%