rushmorem / publicsuffix

An implementation of Mozilla's Public Suffix List in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clarify relationship with addr-rs

FauxFaux opened this issue · comments

The owner of this library seems to also have worked on github.com/addr-rs/addr, which looks similar but abandoned?

Which should we be using?

Personally I was interested in just the domain parsing, so tried to use addr, but noticed it looking outdated. I guess the intention is to use this crate, but to disable the "remote-list" feature?

The owner of this library seems to also have worked on github.com/addr-rs/addr, which looks similar but abandoned?

It's not abandoned. I'm just preoccupied with other things right now. addr is the next iteration of this library.

Which should we be using?

That depends on your use case and the trade-offs you are willing to make.

Personally I was interested in just the domain parsing

In that case I recommend using just using the psl crate. Currently it has horrible compile times and it assumes that the domain name is in lowercase already but in return, you get:-

  1. Super fast runtime performance (faster than any language library I've tested)
  2. No known bugs
  3. The most robust implementation of the public suffix list. It even correctly supports wild cards exactly as they are defined in the spec. No other library I know has support for this.

If you only need to support a few TLDs you can reduce compile times a lot by defining the PSL_TLD or PSL_TLDS environment variable before building.

The README now mentions addr and psl crates but I intent to improve the documentation at some point. In a nutshell, as of v2, psl and publicsuffix crates are just implementations of the public suffix list. They don't try to validate or parse domain names, dns names or email addresses in any way. That's what addr is for.

The difference between psl and publicsuffix is that with psl, the list itself is compiled down to Rust code for optimal performance but because of that, it can't be updated at runtime. That is where publicsuffix comes in. It's dynamic and can be updated at runtime. That also enables it to optionally support anycase domain matching.