Robust domain name parsing using the Public Suffix List
This library allows you to easily and accurately parse any given domain name.
```rust let list = List::from_path("suffix-list.txt").unwrap();
let domain = list.parsednsname("www.example.com")?; asserteq!(domain.name(), "www.example.com"); asserteq!(domain.rname(), "moc.elpmaxe.www"); asserteq!(domain.root(), Some("example.com")); asserteq!(domain.suffix(), Some("com")); assert_eq!(domain.registrable(), Some("example"));
// 2-level TLD let domain = list.parsednsname("wWw.BlUeCaTnEtWoRkS.Uk.CoM.")?; asserteq!(domain.name(), "www.bluecatnetworks.uk.com."); asserteq!(domain.rname(), ".moc.ku.skrowtentaceulb.www"); asserteq!(domain.root(), Some("bluecatnetworks.uk.com.")); asserteq!(domain.suffix(), Some("uk.com.")); assert_eq!(domain.registrable(), Some("bluecatnetworks"));
// the root name let domain = list.parsednsname(".")?; asserteq!(domain.name(), "."); asserteq!(domain.rname(), "."); asserteq!(domain.root(), None); asserteq!(domain.suffix(), None); assert_eq!(domain.registrable(), None); ```