Installations
npm install ds-parse-url
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
7.6.0
NPM Version
4.1.2
Score
72.7
Supply Chain
98.9
Quality
74.8
Maintenance
100
Vulnerability
80.9
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
direktspeed
Download Statistics
Total Downloads
1,904
Last Day
1
Last Week
3
Last Month
13
Last Year
880
GitHub Statistics
Unlicense License
1 Stars
72 Commits
5 Watchers
3 Branches
2 Contributors
Updated on Mar 03, 2017
Bundle Size
203.30 kB
Minified
66.22 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.1.1
Package Id
ds-parse-url@1.1.1
Size
143.55 kB
NPM Version
4.1.2
Node Version
7.6.0
Published on
Mar 03, 2017
Total Downloads
Cumulative downloads
Total Downloads
1,904
Last Day
0%
1
Compared to previous day
Last Week
0%
3
Compared to previous week
Last Month
0%
13
Compared to previous month
Last Year
190.4%
880
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
5
parse-domain
Splits a URL into sub-domain, domain and the top-level domain.
Since domains are handled differently across different countries and organizations, splitting a URL into sub-domain, domain and top-level-domain parts is not a simple regexp. parse-domain uses a large list of known top-level domains from publicsuffix.org to recognize different parts of the domain.
Installation
1npm install --save parse-domain
Usage
1// long subdomains can be handled 2expect(parseDomain("some.subdomain.example.co.uk")).to.eql({ 3 subdomain: "some.subdomain", 4 domain: "example", 5 tld: "co.uk" 6}); 7 8// protocols, usernames, passwords, ports, paths, queries and hashes are disregarded 9expect(parseDomain("https://user:password@example.co.uk:8080/some/path?and&query#hash")).to.eql({ 10 subdomain: "", 11 domain: "example", 12 tld: "co.uk" 13}); 14 15// unknown top-level domains are ignored 16expect(parseDomain("unknown.tld.kk")).to.equal(null); 17 18// invalid urls are also ignored 19expect(parseDomain("invalid url")).to.equal(null); 20expect(parseDomain({})).to.equal(null);
Introducing custom tlds
1// custom top-level domains can optionally be specified 2expect(parseDomain("mymachine.local",{ customTlds: ["local"] })).to.eql({ 3 subdomain: "", 4 domain: "mymachine", 5 tld: "local" 6}); 7 8// custom regexps can optionally be specified (instead of customTlds) 9expect(parseDomain("localhost",{ customTlds:/localhost|\.local/ })).to.eql({ 10 subdomain: "", 11 domain: "", 12 tld: "localhost" 13});
It can sometimes be helpful to apply the customTlds argument using a helper function
1function parseLocalDomains(url) { 2 return parseDomain(url, { 3 customTlds: /localhost|\.local/ 4 }); 5} 6 7expect(parseLocalDomains("localhost")).to.eql({ 8 subdomain: "", 9 domain: "", 10 tld: "localhost" 11}); 12expect(parseLocalDomains("mymachine.local")).to.eql({ 13 subdomain: "", 14 domain: "mymachine", 15 tld: "local" 16});
API
parseDomain(url: string, options: ParseOptions): ParsedDomain|null
Returns null
if url
has an unknown tld or if it's not a valid url.
ParseOptions
1{ 2 // A list of custom tlds that are first matched against the url. 3 // Useful if you also need to split internal URLs like localhost. 4 customTlds: RegExp|Array<string>, 5 6 // There are lot of private domains that act like top-level domains, 7 // like blogspot.com, googleapis.com or s3.amazonaws.com. 8 // By default, these domains would be split into: 9 // { subdomain: ..., domain: "blogspot", tld: "com" } 10 // When this flag is set to true, the domain will be split into 11 // { subdomain: ..., domain: ..., tld: "blogspot.com" } 12 // See also https://github.com/peerigon/parse-domain/issues/4 13 privateTlds: boolean - default: false 14}
ParsedDomain
1{ 2 tld: string, 3 domain: string, 4 subdomain: string 5}
License
Unlicense
Sponsors

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: The Unlicense: LICENSE:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
28 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-832h-xg76-4gv6
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq
- Warn: Project is vulnerable to: GHSA-4hpf-3wq7-5rpr
- Warn: Project is vulnerable to: GHSA-f522-ffg8-j8r6
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q
- Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
Score
1.7
/10
Last Scanned on 2025-02-10
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