Package Exports
- extract-domain
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (extract-domain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Extract domain name from URL
Performant domain name extraction. No regex or array magic.
However. This package will also remove the sub domain.
Support
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').extractDomain;
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'
];
extractDomain(urls[0]); // npmjs.com
extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com', 'example.org' ]
Tests
$ npm test
Coding style
$ npm run pretty
Contribution
Contributions are appreciated.
License
MIT-licensed. See LICENSE.