
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Split domain names into subdomain, registered, and public parts per the Public Suffix List
This is a module for querying the Public Suffix List to determine effective top level domains.
It provides APIs to split domain names into subdomains, registered, and public suffix parts.
Note this module does NOT include a copy of the public suffix list, it downloads the list, caches it, and periodically checks for updates automatically.
As such, internet connectivity is required. If the list is unable to be refreshed, it will continue to run with the last cached version.
For applications that do not have internet connectivity, use an alternate package that includes a copy of the list, or pre-populate the cache file through other means. Note that without periodic updates the list will get out of date.
Cache updates happen on a thread so do not cause processing delays.
See https://publicsuffix.org/ for details about the list.
The package provides the following functions which operate on a single, global list instance:
Initialize the global list. Only needs to be called if not using the default values.
Accepts an optional URL to download the list from, the default is: https://publicsuffix.org/list/public_suffix_list.dat
The list cache will be stored in a file 'public_suffix_list.dat' in the cache_dir, the default cache_dir is '.'.
The refresh_interval defaults to 24 hours.
An optional logger will receive debug and error messages. If a logger is not provided, fatal errors will raise exceptions.
Split a domain name into subdomain, registered name, and publix suffix.
Returns a Tuple of (subdomain, registered name, public suffix).
e.g. www.example.com -> (www, example, com)
Return public suffix of domain name.
e.g. www.example.com -> com
Return registered name of domain name only.
e.g. www.example.com -> example
Return fully qualified registered domain name.
e.g. www.example.com -> example.com
Split a domain name into subdomain and fully qualified registered domain name.
e.g. www.example.com -> (www, example.com)
And the following class:
Instantiate a PublicSuffixList.
Accepts an optional URL to download the list from, the default is: https://publicsuffix.org/list/public_suffix_list.dat
The list cache will be stored in a file 'public_suffix_list.dat' in the cache_dir, the default cache_dir is '.'.
The refresh_interval defaults to 24 hours.
An optional logger will receive debug and error messages. If a logger is not provided, fatal errors will raise exceptions.
Split a domain name into subdomain, registered name, and publix suffix.
Returns a Tuple of (subdomain, registered name, public suffix).
e.g. www.example.com -> (www, example, com)
Return public suffix of domain name.
e.g. www.example.com -> com
Return registered name of domain name only.
e.g. www.example.com -> example
Return registered domain name.
e.g. www.example.com -> example.com
Split a domain name into subdomain and registered domain.
e.g. www.example.com -> (www, example.com)
The protocol for the optional logger.
Print detailed debug information.
Used when downloading the list.
Print a non-fatal error.
Used when the list download fails.
Print a fatal error.
Used when the cache is unavailable and the list is unable to be downloaded or stored.
Install with pip:
pip install public-suffix-list
FAQs
Split domain names into subdomain, registered, and public parts per the Public Suffix List
We found that public-suffix-list demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.