extract tld info from url
Rust
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
benches
examples
src
tests
.gitignore
.travis.yml
Cargo.toml
README.md
TODO.md

README.md

tldExtract Travis Crates.io

A rust implementation of tldExtract. tldExtract accurately extracts TLD, including gTLD(generic top-level domain) and ccTLD ( country code top-level domain) from the domain and subdomains of a URL. For example, it extracts 'google' from 'http://www.google.com'.

Splitting the url with '.' and taking the last 2 elements does not work except for simple examples like .com domains. This does not work for complicated domains like http://forums.bbc.co.uk . The naive splitting method above will give you 'co' as the domain and 'uk' as the TLD, instead of 'bbc' and 'co.uk' respectively.

While tldExtract knows what all gTLDs and ccTLDs look like by looking up the currently living ones according to the Public Suffix List. So, tleExtract knows the subdomain and its domain from its country code.

Thanks to john-kurkowski, this project is mainly inspired by his work in python

documentation