# tld

> node.js module for working with Top-Level Domain data

Latest version **0.0.2** (published 2013-04-12) · MPL2 license · 0 weekly downloads

## Install

```sh
npm install tld
pnpm add tld
yarn add tld
bun add tld
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2013-04-12 |
| Weekly downloads | 0 |
| License | MPL2 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Don Park |
| Maintainers | donpark |
| Keywords | tld |

## Links

- npm: https://www.npmjs.com/package/tld
- Repository: https://github.com/donpark/node-tld
- npm.io page: https://npm.io/package/tld

## Recent versions

- 0.0.2 (latest) — 2013-04-12
- 0.0.1

## README

# node-tld #

## Installation ##

    npm install tld

## Usage ##

### Get registered domain name ###

    var tld = require('tld');
    console.log(tld.registered('www.google.com')); // google.com
    console.log(tld.registered('www.anything.goes.fj')); // anything.goes.fj
    console.log(tld.registered('a.b.c.hyogo.jp')); // b.c.hyogo.jp
    console.log(tld.registered('api.metro.tokyo.jp')); // metro.tokyo.jp
    console.log(TLD.registered('www.foo.bar.sch.uk')); // foo.bar.sch.uk
    console.log(TLD.registered('www.british-library.uk')); // british-library.uk
  
### Hot update TLD data ###

Recent copy of TLD data is bundled within `node-tld` and loaded automatically on first call to `registered`. But if you want to hot update from an URL, following code will download TLD data from `node-tld`'s defaut TLD data source and, if parsed successfully, update in-memory TLD data cache. If `path` is provided, raw TLD data will also be saved to the location.

    var tld = require('tld');
    tld.download(
      'http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1',
      __dirname + '/effective_tld_names.dat');

### Load TLD data file from non-default path ###

If you downloaded more recent copy of TLD data to another path (perhaps using `download` method), you can either change `defaultFile` before first call to `registered` like this:

    var tld = require('tld');
    tld.defaultFile = '.../some/other/path/...';
    // first call triggers loads from above path
    tld.registered('foo.bar.com');

or load explicitly at anytime to switch/update TLD data:

    var tld = require('tld');
    tld.load('.../some/other/path/...');
    // first call triggers loads from above path
    tld.registered('foo.bar.com');

## License ##

This module contains a copy of TLD data file from Mozilla which
is licensed under MPL 2.0. Therefore, this module is also license
under MPL 2.0.

        This Source Code Form is subject to the
        terms of the Mozilla Public License, v.
        2.0. If a copy of the MPL was not
        distributed with this file, You can obtain
        one at http://mozilla.org/MPL/2.0/.

---
_Source: https://npm.io/package/tld · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
