An open API service indexing awesome lists of open source software.

https://github.com/sam0x17/domain-db

crystal langauge shard containing a dynamically updated database of public domain suffixes and top level domain extensions
https://github.com/sam0x17/domain-db

Last synced: 5 months ago
JSON representation

crystal langauge shard containing a dynamically updated database of public domain suffixes and top level domain extensions

Awesome Lists containing this project

README

          

# DomainDB

Contains a dynamically updated database of top level domain extensions (from IANA)
and the public suffixes list from Mozilla.

## Usage

```crystal
require "domain-db"

# suffix list contains everything
DomainDB.update_suffixes
DomainDB.suffixes.includes?("com.mx").should eq true
DomainDB.suffixes.includes?("net").should eq true
DomainDB.tld_extensions.includes?("ninja").should eq true

# tld list just contains top level domains according to IANA
DomainDB.update_tlds
DomainDB.tld_extensions.includes?("com.mx").should eq false # not top level
DomainDB.tld_extensions.includes?("net").should eq true
DomainDB.tld_extensions.includes?("ninja").should eq true
DomainDB.tld_extensions.includes?("co.uk").should eq false # not top level
```

Also see specs for usage for `DomainDB.strip_subdomains` and `DomainDB.strip_suffix`.

## Installation

Add the following to your `shards.yml` file:
```yaml
dependencies:
domain-db:
github: sam0x17/domain-db
```