PublicSuffix
A native Rust library for Mozilla's Public Suffix List
This library uses Mozilla's Public Suffix List to reliably determine the suffix of a domain name. This crate provides a dynamic list that can be updated at runtime. If you need a faster, though static list, please use the psl crate instead.
NB: v1 of this crate contained logic to validate domain names and email addresses. Since v2, this functionality was moved to the addr crate. This crate also no longer downloads the list for you.
Setting Up
Add this crate to your Cargo.toml
:
[]
= "2"
Examples
use ;
// the official list can be found at
// https://publicsuffix.org/list/public_suffix_list.dat
let list: List = "<-- your public suffix list here -->".parse?;
let suffix = list.suffix?;
assert_eq!;
assert_eq!;
let domain = list.domain?;
assert_eq!;
assert_eq!;
let domain = list.domain?;
assert_eq!;
assert_eq!;
let domain = list.domain?;
assert_eq!;
assert_eq!;
let domain = list.domain?;
assert_eq!;
assert_eq!;
let domain = list.domain?;
assert_eq!;
assert_eq!;