ReservedSubdomain
ReservedSubdomain is a Ruby gem that checks whether a proposed subdomain should be a reserved name.
It checks for common patterns such as www
or mail
. It checks all gTLDs. It checks some common language and country codes.
Installation
Add this line to your application's Gemfile:
gem 'reserved_subdomain'
Usage
ReservedSubdomain.new('www').reserved? # => true
Reserved subdomains
The actual subdomain names that are marked as reserved can be found in the text files in the literals directory.
Configuration
Each time you use ReservedSubdomain it loads the list of reserved names from a file. This can be slow if you're doing these checks frequently.
In this case you can set the environment variable RESERVED_SUBDOMAIN_PRELOAD
to "true" and the list will be preloaded.
Of course if you preload the list it will stay memory-resident and take up a significant amount of room. Your call.
Contributing
- Fork the repo into your own account.
- Copy the
Gemfile.local.example
toGemfile.local
and edit as you see fit. - Organize your changes into easy-to-understand commits.
- Submit a pull request for me to merge.
If you need to update the text files, run the bin/build_literals
job to ensure there are no duplicates.