Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cogini/public_suffix_list
Elixir library which uses the https://publicsuffix.org/ list to parse DNS domains
https://github.com/cogini/public_suffix_list
dns elixir-library publicsuffixlist
Last synced: about 2 months ago
JSON representation
Elixir library which uses the https://publicsuffix.org/ list to parse DNS domains
- Host: GitHub
- URL: https://github.com/cogini/public_suffix_list
- Owner: cogini
- License: apache-2.0
- Created: 2019-10-04T05:15:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-01T02:17:31.000Z (about 1 year ago)
- Last Synced: 2024-09-16T17:53:08.835Z (4 months ago)
- Topics: dns, elixir-library, publicsuffixlist
- Language: Elixir
- Homepage:
- Size: 140 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![test workflow](https://github.com/cogini/public_suffix_list/actions/workflows/test.yml/badge.svg)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)# public_suffix_list
Parse DNS domain names using public suffix list from https://publicsuffix.org
The public suffix list distinguishes registrable domains from the "suffix" of
the domain. For simple TLDs like `.com`, it's clear which part is the name, but
there are many compound suffixes like `.ac.uk`, and it becomes difficult to
tell what part is the name.This list was originally defined by Mozilla to make sure that websites
could not set cookies on suffixes. It is also useful for normalizing
domains into registrable name, suffix and any subdomains.This library reads the standard `public_suffix_list.dat` and generates
a `parse/1` function which matches domains against it, splitting them
into host/subdomains, name, and suffix:```elixir
iex(1)> PublicSuffixList.parse("www.ic.ac.uk")
{:ok, {["www"], "ic", "ac.uk"}}
```It also defines utility functions, `normalize/1` which removes the subdomains
and `name/1` which gets just the domain:```elixir
iex(2)> PublicSuffixList.normalize("www.ic.ac.uk")
{:ok, "ic.ac.uk"}iex(3)> PublicSuffixList.name("www.ic.ac.uk")
{:ok, "ic"}
```## Installation
Add `public_suffix_list` to the list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:public_suffix_list, "~> 0.1.0"}
]
end
```The docs can be found at [https://hexdocs.pm/public_suffix_list](https://hexdocs.pm/public_suffix_list).