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
@hutson/parse-repository-url
Parse repository URLs to extract, SCM platform, domain, user, and project information.
tld-extract
Extract the TLD/domain/subdomain parts of an URL/hostname against mozilla TLDs 'official' listing .
@types/extract-domain
TypeScript definitions for extract-domain
@aegenet/belt-extract-domain
Extract domain informations
npm install extract-domain
Typescript
Module System
Node Version
NPM Version
JavaScript (63.52%)
TypeScript (36.48%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
31 Stars
101 Commits
4 Forks
3 Watchers
3 Branches
3 Contributors
Updated on Nov 02, 2024
Latest Version
5.0.2
Package Id
extract-domain@5.0.2
Unpacked Size
230.45 kB
Size
76.04 kB
File Count
15
NPM Version
10.2.3
Node Version
20.10.0
Published on
Apr 09, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
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
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
detected GitHub workflow tokens with excessive permissions
Details
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
15 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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