• Stars
    star
    270
  • Rank 152,189 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript Library to work against complex domain names, subdomains and URIs.

tldts - Blazing Fast URL Parsing

NPM

Build Status Known Vulnerabilities

tldts is a JavaScript library to extract hostnames, domains, public suffixes, top-level domains and subdomains from URLs.

Features:

  1. Tuned for performance (order of 0.1 to 1 μs per input)
  2. Handles both URLs and hostnames
  3. Full Unicode/IDNA support
  4. Support parsing email addresses
  5. Detect IPv4 and IPv6 addresses
  6. Continuously updated version of the public suffix list
  7. TypeScript, ships with umd, esm, cjs bundles and type definitions
  8. Small bundles and small memory footprint
  9. Battle tested: full test coverage and production use

Install

npm install --save tldts

Usage

Using the command-line interface:

$ npx tldts 'http://www.writethedocs.org/conf/eu/2017/'
{
  "domain": "writethedocs.org",
  "domainWithoutSuffix": "writethedocs",
  "hostname": "www.writethedocs.org",
  "isIcann": true,
  "isIp": false,
  "isPrivate": false,
  "publicSuffix": "org",
  "subdomain": "www"
}

Or from the command-line in batch:

$ echo "http://www.writethedocs.org/\nhttps://example.com" | npx tldts
{
  "domain": "writethedocs.org",
  "domainWithoutSuffix": "writethedocs",
  "hostname": "www.writethedocs.org",
  "isIcann": true,
  "isIp": false,
  "isPrivate": false,
  "publicSuffix": "org",
  "subdomain": "www"
}
{
  "domain": "example.com",
  "domainWithoutSuffix": "example",
  "hostname": "example.com",
  "isIcann": true,
  "isIp": false,
  "isPrivate": false,
  "publicSuffix": "com",
  "subdomain": ""
}

Programmatically:

const { parse } = require('tldts');

// Retrieving hostname related informations of a given URL
parse('http://www.writethedocs.org/conf/eu/2017/');
// { domain: 'writethedocs.org',
//   domainWithoutSuffix: 'writethedocs',
//   hostname: 'www.writethedocs.org',
//   isIcann: true,
//   isIp: false,
//   isPrivate: false,
//   publicSuffix: 'org',
//   subdomain: 'www' }

Modern ES6 modules import is also supported:

import { parse } from 'tldts';

Alternatively, you can try it directly in your browser here: https://npm.runkit.com/tldts

Check README.md for more details about the API.

Contributors

tldts is based upon the excellent tld.js library and would not exist without the many contributors who worked on the project.

This project would not be possible without the amazing Mozilla's public suffix list either. Thank you for your hard work!

License

MIT License.

More Repositories

1

Hodor

One Brainfuck interpreter to rule them all!
Brainfuck
36
star
2

Bison-Flex-CPP-template

A C++ template for Bison / Flex projects
C++
31
star
3

bandwidth-monitor

Simple project to continuously measure the bandwidth of your home Internet connection
Python
19
star
4

blockrz

Super minimal blocker of ads, trackers and annoyances.
TypeScript
16
star
5

wgraph

Etymological graphs based on Wiktionary dumps
Python
14
star
6

mono

A monorepo of TypeScript libraries I maintain
TypeScript
13
star
7

https-everywhere-core

A more efficient matching engine for HTTPS Everywhere written in pure JavaScript
TypeScript
11
star
8

privacy_bot

Privacy bot crawls privacy policies of popular domains, persist them and analyze them.
Python
6
star
9

remusao.github.io

My personal blog
CSS
5
star
10

LDA.jl

*Deprecated* - Linear Discriminant Analysis and Kernel Fisher Analysis
Julia
5
star
11

simple-sanic

A faster http.server using sanic
Python
3
star
12

Wikipedia.jl

*Deprecated* - A julia wrapper over Wikipedia API
Julia
3
star
13

tsmaz

tsmaz has moved to https://github.com/remusao/mono/tree/master/packages/smaz
3
star
14

firefox-67-idb-bug-repro

Minimal extension to reproduce an IndexedDB bug happening in Firefox 67
JavaScript
3
star
15

node-app-packaging-template

Minimal template to package Node.js projects: minified bundle, self-contained executable, docker
JavaScript
2
star
16

twitter-adblocker

Simple extension to block ads on Twitter
JavaScript
2
star
17

Sumup.jl

Automatic multi-documents, multi-topics summarization based on topic extraction
Julia
2
star
18

Brainfuck.jl

Simple brainfuck interpreter written in Julia
Julia
1
star
19

NGram.jl

Implement the NGram model in julia
Julia
1
star
20

Prpa

A multi-threaded video stream processing.
C++
1
star
21

broxy

Your Privacy Bro!
JavaScript
1
star
22

PythonMatching

A Python module that allows OCaml-like pattern-matching.
Python
1
star
23

metaheuristic

Metaheuristic toolbox
C++
1
star
24

PyCheck

A general purpose TestSuit written in Python for projects of any size.
Python
1
star
25

Data_Structs

A set of generic data structures to use in a C project
C++
1
star
26

KSVM.jl

Kernel SVM written in Julia
Julia
1
star
27

thunderbird-msg-filters

thunderbird-msg-filters has moved to https://github.com/remusao/mono/tree/master/packages/thunderbird-msg-filters
1
star
28

katas

Katas'trophe
Python
1
star
29

CPP_Coding_Style_Checker

A program that check a C++ file (source or header) and output each coding bad style on output.
C++
1
star
30

site-pinning

Web-extension allowing to pin sub-resources to get reproducible page loading
JavaScript
1
star
31

haskell-goggle

Brave Search Goggle to rerank results and boost content related to the Haskell programming language.
1
star