This crate provides a very simple interface for checking hosts against the Public Suffix List.
This is a judgey library; hosts with unknown or missing suffixes are not parsed. No distinction is made between ICANN and private entries.
Rules must be followed! Haha.
For hosts that do get parsed, their values will be normalized to lowercase ASCII.
Note: The master suffix data is baked into this crate at build time. This reduces the runtime overhead of parsing all that data out, but can also cause implementing apps to grow stale if they haven't been (re)packaged in a while.
Initiate a new instance using Domain::parse
. If that works, you then have accesses to the individual components:
```rust use adbyss_psl::Domain;
let dom = Domain::parse("www.MyDomain.com").unwrap(); asserteq!(dom.host(), "www.mydomain.com"); asserteq!(dom.subdomain(), Some("www")); asserteq!(dom.root(), "mydomain"); asserteq!(dom.suffix(), "com"); assert_eq!(dom.tld(), "mydomain.com"); ```
A Domain
object can be dereferenced to a string slice representing the sanitized host. You can also consume the object into an owned string with Domain::take
.
Copyright © 2021 Blobfolio, LLC <hello@blobfolio.com>
This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.