Gathering detailed insights and metrics for ds-parse-url
Gathering detailed insights and metrics for ds-parse-url
Gathering detailed insights and metrics for ds-parse-url
Gathering detailed insights and metrics for ds-parse-url
npm install ds-parse-url
Typescript
Module System
Node Version
NPM Version
72.7
Supply Chain
98.9
Quality
74.8
Maintenance
100
Vulnerability
80.9
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,904
Last Day
1
Last Week
3
Last Month
13
Last Year
880
Unlicense License
1 Stars
72 Commits
5 Watchers
3 Branches
2 Contributors
Updated on Mar 03, 2017
Minified
Minified + Gzipped
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
Cumulative downloads
Total Downloads
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
2
5
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.
1npm install --save parse-domain
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);
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});
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}
Unlicense
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
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
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
28 existing vulnerabilities detected
Details
Score
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