Coder Social home page Coder Social logo

public_suffix_list's Introduction

test workflow Contributor Covenant

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:

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:

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:

def deps do
  [
    {:public_suffix_list, "~> 0.1.0"}
  ]
end

The docs can be found at https://hexdocs.pm/public_suffix_list.

public_suffix_list's People

Contributors

reachfh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

hgdata

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.