PublicSufx (public_sufx v0.6.0)
View SourceImplements the publicsuffix algorithm described at https://publicsuffix.org/list/.
Summary
Functions
Parses the provided domain and returns the prevailing rule based on the
publicsuffix.org rules. If no rules match, the prevailing rule is "*",
unless the provided domain has a leading dot, in which case the input is
invalid and the function returns nil
.
Extracts the public suffix from the provided domain based on the publicsuffix.org rules.
Returns true if the supplied domain is a public suffix based on the publicsuffix.org rules, false otherwise.
Functions
Parses the provided domain and returns the prevailing rule based on the
publicsuffix.org rules. If no rules match, the prevailing rule is "*",
unless the provided domain has a leading dot, in which case the input is
invalid and the function returns nil
.
Examples
iex> prevailing_rule("foo.bar.com")
"com"
iex> prevailing_rule("co.uk")
"co.uk"
iex> prevailing_rule("foo.ck")
"*.ck"
iex> prevailing_rule("foobar.example")
"*"
iex> prevailing_rule("foo.github.io")
"github.io"
Extracts the public suffix from the provided domain based on the publicsuffix.org rules.
Examples
iex> public_suffix("foo.bar.com")
"com"
iex> public_suffix("foo.github.io")
"github.io"
Returns true if the supplied domain is a public suffix based on the publicsuffix.org rules, false otherwise.
Examples
iex> public_suffix?("foo.bar.com")
false
iex> public_suffix?("com")
true
iex> public_suffix?("foo.github.io")
false
iex> public_suffix?("github.io")
true