0.0
The project is in a healthy, maintained state
Extract root domain from hosts (e.g. www.example will be extracted as example.com). It normalizes punycode domains and considers second-level domain names.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies
 Project Readme

root_domain

Tests Code Climate Gem Gem

If you ever worked with domain validation, you probably needed to extract the root domain. This means that, given some hostname, you must remove subdomains from the original input, taking into account not only official Internet TLDs, but SLDs too.

With root_domain, you can easily extract the root domain, expanding any input from punycode into ASCII entries.

Installation

gem install root_domain

Or add the following line to your project's Gemfile:

gem "root_domain"

Usage

require "root_domain"

RootDomain.call("www.example.com")
#=> example.com

RootDomain.call("www.example.com.br")
#=> example.com.br

RootDomain.call("myapp.apps.🤯.com")
#=> xn--oq9h.com

Maintainer

Contributors

Contributing

For more details about how to contribute, please read https://github.com/fnando/root_domain/blob/main/CONTRIBUTING.md.

License

The gem is available as open source under the terms of the MIT License. A copy of the license can be found at https://github.com/fnando/root_domain/blob/main/LICENSE.md.

Code of Conduct

Everyone interacting in the root_domain project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.