Public Domain-Suffix Extraction Library for Ruby
The Public Suffix List is a cross-vendor initiative to provide an accurate list of domain name suffixes. [..] It is available for use in any software, but was originally created to meet the needs of browser manufacturers.
A “public suffix” is one under which Internet users can directly register names. Some examples of public suffixes are “.com”, “.co.uk” and “pvt.k12.wy.us”. The Public Suffix List is a list of all known public suffixes.
public_suffix_service makes it easy to parse any domain name into its TLD, unique domain name, and subdomain portions, following the myriad of rules regarding all of the different TLDs that currently exist.