The gem public_suffix is a domain name parser, written in Ruby, and based on the Public Suffix List.
The library is trusted by several large companies and applications, including:
- GitHub pages (via
github-pages-health-check
) - DNSimple
PublicSuffix.domain("google.com")
# => "google.com"
PublicSuffix.domain("www.google.com")
# => "google.com"
PublicSuffix.domain("www.google.co.uk")
# => "google.co.uk"