Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thoughtindustries/tldextract

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thoughtindustries/tldextract

Extract domain, subdomain and tld from a url

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
472
increased by26.54%
Maintainers
1
Weekly downloads
 
Created
Source

tldextract

Accurately separates the gTLD or ccTLD (generic or country code top-level domain) from the registered domain and subdomains of a URL.

How does it work?

const tldExtract = require('@thoughtindustries/tldextract');

try {
  const data1 = tldExtract('https://forums.news.cnn.com/');
  // data1 = { subdomain: 'forums.news', domain: 'cnn', tld: 'com' }
    
  const data2 = tldExtract('https://forums.news.cnn.com/');
  // data2 = { subdomain: 'ye', domain: 'ye', tld: 'ye.ye' }
} catch (e) {
  // e.message === 'No domain/IP detected' if there is an error
  console.error(e);
}

tests

npm run test

Disclaimer

This module is a port of the python module tldextract.

Keywords

FAQs

Package last updated on 19 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc