6 releases (breaking)

0.6.0 Aug 10, 2022
0.5.1 Sep 11, 2018
0.5.0 Oct 30, 2017
0.4.0 Feb 9, 2017
0.1.0 Nov 12, 2016

#100 in Internationalization (i18n)

Download history 1172/week @ 2023-12-06 1427/week @ 2023-12-13 1953/week @ 2023-12-20 474/week @ 2023-12-27 2427/week @ 2024-01-03 1993/week @ 2024-01-10 929/week @ 2024-01-17 1613/week @ 2024-01-24 1766/week @ 2024-01-31 1349/week @ 2024-02-07 1200/week @ 2024-02-14 2228/week @ 2024-02-21 1855/week @ 2024-02-28 1835/week @ 2024-03-06 1868/week @ 2024-03-13 1547/week @ 2024-03-20

7,363 downloads per month
Used in 10 crates (4 directly)

MIT license

155KB
7.5K SLoC

tldExtract Build Status 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

Dependencies

~4–19MB
~278K SLoC