New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

extract-domain

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-domain

Extract domain name from URL

  • 2.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57K
decreased by-5.16%
Maintainers
1
Weekly downloads
 
Created
Source

Extract domain name from URL

Donate Travis

Performant domain name extraction. No regex or array magic.

What is an URL

However. This package will also remove the sub domain.

Supports

Browser and Node.

Usage

$ npm i --save extract-domain
  • urls = string|array
  • returns string|array
extractDomain(urls);

ES6

import extractDomain from 'extract-domain';
const extractDomain = require('extract-domain');
const urls = [
    'https://www.npmjs.com/package/extract-domain',
    'http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
    'http://user:password@example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
    'https://npmjs.com/package/extract-domain',
    'ftp://example.org/resource.txt',
    'this.is.my@email.com'
];


extractDomain(urls[0]); // npmjs.com

extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com', 'example.org', 'email.com' ]

Tests

$ npm test

Coding style

$ npm run pretty

Benchmark

$ npm run benchmark

Contribution

Contributions are appreciated.

License

MIT-licensed. See LICENSE.

Donation

If this project has been helpful in any way, and you want to treat me a cup of coffee, please donate :)

paypal

Keywords

FAQs

Package last updated on 04 Apr 2019

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