MCPcopy Index your code
hub / github.com/addr-rs/psl

github.com/addr-rs/psl @v2.1.216

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.1.216 ↗ · + Follow
17 symbols 26 edges 6 files 3 documented · 18%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

PSL

A native Rust library for Mozilla's Public Suffix List

CI Publish Latest Version Crates.io downloads Docs Minimum supported Rust version Maintenance License

This library uses Mozilla's Public Suffix List to reliably determine the suffix of a domain name.

It compiles the list down to native Rust code for ultimate speed. This list compilation is done as a separate step by the Publish GitHub Action so the crate still compiles very quickly. The Publish action automatically checks for updates everyday and pushes an updated crate to crates.io if there were any updates in the upstream domain suffixes. This keeps the crate automatically synchronised with the official list.

If you need a dynamic list that can be updated at runtime, though a bit slower, please use the publicsuffix crate instead (which also has optional support for looking up domain names in any case).

Setting Up

Add this crate to your Cargo.toml:

[dependencies]
psl = "2"

Examples

let suffix = psl::suffix(b"www.example.com")?;
assert_eq!(suffix, "com");
assert_eq!(suffix.typ(), Some(psl::Type::Icann));

let domain = psl::domain(b"www.example.com")?;
assert_eq!(domain, "example.com");
assert_eq!(domain.suffix(), "com");

let domain = psl::domain("www.食狮.中国".as_bytes())?;
assert_eq!(domain, "食狮.中国");
assert_eq!(domain.suffix(), "中国");

let domain = psl::domain(b"www.xn--85x722f.xn--55qx5d.cn")?;
assert_eq!(domain, "xn--85x722f.xn--55qx5d.cn");
assert_eq!(domain.suffix(), "xn--55qx5d.cn");

let domain = psl::domain(b"a.b.example.uk.com")?;
assert_eq!(domain, "example.uk.com");
assert_eq!(domain.suffix(), "uk.com");

let domain = psl::domain(b"_tcp.example.com.")?;
assert_eq!(domain, "example.com.");
assert_eq!(domain.suffix(), "com.");

Extension points exported contracts — how you extend this code

TldExtract (Interface)
(no doc) [1 implementers]
examples/tldextract.rs

Core symbols most depended-on inside this repo

msg
called by 7
tests/list.rs
expected_tld
called by 3
tests/list.rs
find
called by 1
src/lib.rs
suffix
called by 1
src/lib.rs
domain
called by 1
src/lib.rs
extract
called by 1
examples/tldextract.rs
bench_find
called by 0
benches/benches.rs
bench_suffix
called by 0
benches/benches.rs

Shape

Function 12
Class 2
Method 2
Interface 1

Languages

Rust100%

Modules by API surface

src/lib.rs6 symbols
tests/list.rs4 symbols
examples/tldextract.rs4 symbols
benches/benches.rs3 symbols

For agents

$ claude mcp add psl \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact