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

parse-domains

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-domains

Domain parser that automatically updates its suffix lists from Mozilla's publicsuffix.org

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Parse Domains

NPM

The MIT License github-package.json-version github-top-lang

This module is a complete rewrite of parse-domains version 1.x.x in order to make use of Mozilla's fantastic publicsuffix list.

It was written while benchmarking against tldts which is super fast but has to be updated with every new suffix added to the public suffix list.

Instead, this module automatically downloads the public list once a day only as recommended by publicsuffix.org. The new list is then loaded to memory once to keep the library super fast.

Generally, parsing most domains takes less than one millisecond. While not as fast as tldts, it parses in 1ms or less and you will never have to upgrade the module to a higher version just to get the latest suffixes.

Usage

async () => {
	let parse = require('parse-domains');
  // notice this method returns a promise
  // So either use the async/await pattern or the Promise.then pattern
	let resp = await parse('http://www.google.co.uk');
	console.log(resp);
};

This will log:

{
  tld: 'co.uk',
  domain: 'google.co.uk',
  subdomain: 'www',
  siteName: 'google',
  href: 'http://www.google.co.uk/',
  hostname: 'www.google.co.uk',
  protocol: 'http:'
}

Keywords

FAQs

Package last updated on 01 Nov 2022

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