Gathering detailed insights and metrics for extract-domain
Gathering detailed insights and metrics for extract-domain
Gathering detailed insights and metrics for extract-domain
Gathering detailed insights and metrics for extract-domain
npm install extract-domain
99.6
Supply Chain
100
Quality
78.7
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
31 Stars
101 Commits
4 Forks
4 Watching
3 Branches
3 Contributors
Updated on 02 Nov 2024
Minified
Minified + Gzipped
JavaScript (63.52%)
TypeScript (36.48%)
Cumulative downloads
Total Downloads
Last day
8.5%
11,610
Compared to previous day
Last week
12.3%
54,946
Compared to previous week
Last month
18.9%
223,005
Compared to previous month
Last year
48.5%
2,292,277
Compared to previous year
1
6
This package provides a performant way to extract domain names from URLs without using regular expressions or array manipulations.
Learn more about What is a URL
1$ npm i --save extract-domain
# Install bun https://bun.sh/
curl -fsSL https://bun.sh/install | bash
# tests
bun test:watch
{ tld: true }
permit to get Top Level Domain like *.co.uk
ESM import
1import extractDomain from 'extract-domain';
Examples
1const urls = [ 2 'https://www.npmjs.com/package/extract-domain', 3 'http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument', 4 'http://user:password@example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument', 5 'https://npmjs.com/package/extract-domain', 6 'ftp://example.org/resource.txt', 7 'http://example.co.uk/', 8 'this.is.my@email.com', 9]; 10 11extractDomain(urls[0]); // npmjs.com 12 13extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com', 'example.org', 'co.uk', 'email.com' ]
TLD support requires the optional dependency of the psl
library.
Examples
1npm i --save-optional psl
1const url = 2 'http://www.example.co.uk:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument'; 3 4async function extract(url) { 5 console.log(await extractDomain(url, { tld: true })); 6 // example.co.uk 7} 8 9// Or 10extractDomain(url, { tld: true }).then(console.log); 11// example.co.uk
Please note that using the tld flag may significantly slow down the process. Benchmark (old) results:
# extract domain 10,000 times
end ~14 ms (0 s + 13572914 ns)
# extract domain with tld 10,000 times
end ~4.29 s (4 s + 288108681 ns)
1$ bun test
1$ bun pretty
1$ bun benchmark
Contributions are appreciated.
MIT-licensed. See LICENSE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More