list-of-top-level-domains/README.md

192 lines
6.0 KiB
Markdown
Raw Normal View History

2017-12-14 05:26:09 +00:00
# TLD Enumerations
2018-06-13 00:23:35 +00:00
Lists of every [IANA TLD](http://data.iana.org/TLD/tlds-alpha-by-domain.txt) in various formats. The lists may be continuously updated using the [included utility](#updating-the-tld-lists) that pulls the latest data from IANA.
2012-10-27 11:41:50 +00:00
2018-06-13 00:20:10 +00:00
* [CSV format](./tlds.csv)
* [All Formats](#tld-list-formats)
2018-06-13 00:21:09 +00:00
* [Updating the TLDs](#updating-the-tld-lists)
2018-06-13 00:10:09 +00:00
* [Node Usage](#node-usage)
* [PHP Usage](#php-usage)
2018-06-13 00:20:10 +00:00
2017-12-14 06:34:39 +00:00
## Usage
2018-06-13 00:20:10 +00:00
Because the lists are provided in universial CSV and JSON formats, they easily utilitized in most programming environments.
2018-06-13 00:21:52 +00:00
Additionally, for convenience, some native programming language formats have also been provided.
2018-06-13 00:20:10 +00:00
* [Node Usage](#node-usage)
* [PHP Usage](#php-usage)
2017-12-14 06:05:44 +00:00
2018-06-13 00:10:09 +00:00
### Node Usage
2017-12-14 06:38:21 +00:00
* use npm to add the `tld-enum` package to your project
2017-12-14 06:05:44 +00:00
```sh
$ npm install tld-enum --save
```
2017-12-14 06:34:39 +00:00
* add the module to your source
```js
const tldEnum = require('tld-enum');
```
* access the list by using the `tldEnum.tldList` array
```js
const tldEnum = require('tld-enum');
tldEnum.tldList; //an array with every IANA TLD
```
The following example...
```js
const tldEnum = require('tld-enum');
console.log("There are " + tldEnum.tldList.length + " IANA TLDs");
let tldCheck;
tldCheck = "com";
console.log("Is '" + tldCheck + "' a real TLD?");
if (tldEnum.tldList.indexOf(tldCheck.toLowerCase()) != -1) {
console.log(" yes");
2017-12-14 06:34:39 +00:00
} else {
console.log(" no");
2017-12-14 06:34:39 +00:00
}
tldCheck = "somethingWeird";
console.log("Is '" + tldCheck + "' a real TLD?");
if (tldEnum.tldList.indexOf(tldCheck.toLowerCase()) != -1) {
console.log(" yes");
2017-12-14 06:34:39 +00:00
} else {
console.log(" no");
2017-12-14 06:34:39 +00:00
}
```
Should produce the following output...
```txt
There are 1573 IANA TLDs
Is 'com' a real TLD?
yes
Is 'somethingWeird' a real TLD?
no
```
2017-12-14 06:05:44 +00:00
2018-06-13 00:10:09 +00:00
### PHP Usage
2017-12-14 06:38:21 +00:00
* use composer to add the `katmore/tld-enum` package to your project
2017-12-14 06:05:44 +00:00
```sh
2017-12-14 06:34:39 +00:00
$ composer require katmore/tld-enum
```
* access the list by using the `\TldEnum\TldEnum::TLD_ENUM` class constant array
2017-12-14 06:38:21 +00:00
```php
2017-12-14 06:55:07 +00:00
<?php
2017-12-14 06:38:21 +00:00
require_once __DIR__ . '/vendor/autoload.php';
\TldEnum\TldEnum::TLD_ENUM; //an array with every IANA TLD
```
2017-12-14 06:34:39 +00:00
The following example...
```php
<?php
use TldEnum\TldEnum;
require __DIR__ . '/vendor/autoload.php';
echo "There are " . count(TldEnum::TLD_ENUM) . " IANA TLDs\n";
$tldCheck = "com";
echo "Is '$tldCheck' a real TLD?\n";
if (in_array(strtolower($tldCheck), TldEnum::TLD_ENUM)) {
echo " yes\n";
2017-12-14 06:34:39 +00:00
} else {
echo " no\n";
2017-12-14 06:34:39 +00:00
}
$tldCheck = "somethingWeird";
echo "Is '$tldCheck' a real TLD?\n";
if (in_array(strtolower($tldCheck), TldEnum::TLD_ENUM)) {
echo " yes\n";
2017-12-14 06:34:39 +00:00
} else {
echo " no\n";
2017-12-14 06:34:39 +00:00
}
```
2017-12-14 06:51:08 +00:00
Should produce the following output...
2017-12-14 06:34:39 +00:00
```txt
There are 1573 IANA TLDs
Is 'com' a real TLD?
yes
Is 'somethingWeird' a real TLD?
no
2017-12-14 06:05:44 +00:00
```
2017-12-14 06:51:08 +00:00
## Examples
* [php-demo.php](/examples/php-demo.php)
* [js-demo.js](/examples/js-demo.js)
2018-06-13 00:10:09 +00:00
## TLD List Formats
* **CSV**: [tlds.csv](/tlds.csv)
A CSV file providing a row for each TLD with the following three columns: *domain* (TLD), *description*, and *type*.
2017-12-13 20:37:50 +00:00
* **PHP**: [TldEnum.php](/formats/php/TldEnum/TldEnum.php)
2017-12-04 22:40:06 +00:00
2017-12-14 05:26:09 +00:00
A PHP source file providing a class with a constant having an array value comprised of every IANA TLD.
2017-12-04 22:40:06 +00:00
2017-12-13 20:37:50 +00:00
* **JSON**: [tld-list.json](/formats/json/tld-list.json)
2017-12-04 22:40:06 +00:00
2017-12-14 05:26:09 +00:00
A JSON formatted array comprised of every IANA TLD.
2017-12-04 22:40:06 +00:00
2017-12-13 21:23:52 +00:00
* **JavaScript**: [tld-enum.js](/formats/js/tld-enum.js)
2017-12-04 22:40:06 +00:00
2017-12-14 05:26:09 +00:00
An export module with a constant having an array value comprised of every IANA TLD.
2017-12-14 06:05:44 +00:00
## Updating the TLD lists
2018-06-13 00:10:09 +00:00
All [TLD List Formats](#tld-list-formats) can be with the latest data from IANA by using the [**TLD Update Utility**](/bin/update-formats.sh).
```sh
$ bin/update-formats.sh
```
### TLD Update Utility Prerequisites
* Node.js version 8.11 or higher.
* (Optional) PHP command-line version 7.2 or higher, to create the [PHP format class file](#tld-list-formats).
### TLD Update Utility Usage
```txt
usage:
update-formats.sh [-h] | [-q][--skip-php]
options:
-h,--help: Print a help message and exit.
-q,--quiet: Print less messages.
--force-php: Creating the PHP format file is mandatory.
--skip-php: Always skip creating the PHP format file
```
### TLD Update Helpers
Internally, the *TLD Update Utility* uses multiple *"helper" scripts* to generate the full set of native format lists.
These individual *"helper" scripts* should not be directly executed except for development and troubleshooting purposes.
2017-12-04 21:56:31 +00:00
## Legal
2017-12-04 22:40:06 +00:00
The source code in this project is based on a fork of certain source code originally from the [incognico/list-of-top-level-domains](https://github.com/incognico/list-of-top-level-domains) project, as retrieved on 2017-12-04, which was published to the public domain.
2017-12-04 21:56:31 +00:00
### Copyright
2017-12-14 05:26:09 +00:00
TLD Enumerations - https://github.com/katmore/tld-enum
2017-12-04 21:56:31 +00:00
The following copyright notice applies to all resources in this project unless specifically noted otherwise:
2018-06-12 21:22:03 +00:00
Copyright (c) 2017-2018 Doug Bird. All Rights Reserved.
2017-12-13 20:22:57 +00:00
### Public Domain Resources
The following resources of this project are hereby released into the public domain:
2018-06-12 21:22:03 +00:00
* [tlds.csv](/tlds.csv)
* [formats/js/tld-enum.js](/formats/js/tld-list.js)
* [formats/json/tld-list.json](/formats/json/tld-list.json)
* [formats/php/TldEnum/TldEnum.php](/formats/php/TldEnum/TldEnum.php)
* [assets/tld-desc.csv](/assets/tld-desc.csv)
2017-12-04 21:56:31 +00:00
### License
All resources in the 'TLD Enumerations' project are copyrighted free software unless specifically noted otherwise.
2017-12-04 21:56:31 +00:00
You may redistribute and modify it under either the terms and conditions of the
"The MIT License (MIT)"; or the terms and conditions of the "GPL v3 License".
See [LICENSE](/LICENSE) and [GPLv3](/GPLv3).
2017-12-13 20:23:47 +00:00
These licensing conditions do not apply to any resources that have been released into the public domain; which are listed in the [**"Public Domain Resources"**](/README.md#public-domain-resources) section of the 'TLD Enumerations' project's [README](/README.md) document.