Karta.PublicSuffix.Rules (Karta v1.0.0)

Reads a copy of the Public Suffix List (Karta.PublicSuffix): its rules (parse/1), its version (version/1), and whether a copy fetched from elsewhere is the list at all (check/1) before Karta uses it.

A rule is the first word of a line that is not a comment (//); *.kobe.jp is a wildcard and !city.kobe.jp an exception. U-labels are converted to A-labels; a rule that cannot be converted makes the copy unusable.

Summary

Types

{kind, name} for each rule: co.uk, *.kobe.jp as kobe.jp, !city.kobe.jp as city.kobe.jp.

Functions

The rules of a copy fetched from elsewhere, once it looks like the list: between 100 KB and 4 MB of UTF-8 text, with both sections (ICANN and private), every rule readable, at least 5,000 rules, among them some that every copy has had for years. Otherwise {:error, reason}.

The largest copy accepted, in bytes.

The rules of a copy of the list, or why it cannot be read.

The version a copy names in its header (// VERSION: …), or nil.

Types

rules()

@type rules() :: %{required({:rule | :wildcard | :exception, String.t()}) => true}

{kind, name} for each rule: co.uk, *.kobe.jp as kobe.jp, !city.kobe.jp as city.kobe.jp.

Functions

check(text)

@spec check(binary()) :: {:ok, rules()} | {:error, String.t()}

The rules of a copy fetched from elsewhere, once it looks like the list: between 100 KB and 4 MB of UTF-8 text, with both sections (ICANN and private), every rule readable, at least 5,000 rules, among them some that every copy has had for years. Otherwise {:error, reason}.

max_size()

@spec max_size() :: pos_integer()

The largest copy accepted, in bytes.

parse(text)

@spec parse(binary()) :: {:ok, rules()} | {:error, String.t()}

The rules of a copy of the list, or why it cannot be read.

version(text)

@spec version(binary()) :: String.t() | nil

The version a copy names in its header (// VERSION: …), or nil.