Package Exports
- parse-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 (parse-domain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
parse-domain
Splits an url into sub-domain, domain and top-level-domain.
Since domains are handled differently across different countries and organizations, splitting an url into sub-domain, domain and top-level-domain is not a simple regexp. parse-domain uses a large list of known tlds (borrowed from http://publicsuffix.org) to recognize different parts of the domain.
var parseDomain = require("parse-domain");
expect(parseDomain("some.subdomain.example.co.uk")).to.eql({
subdomain: "some.subdomain",
domain: "example",
tld: "co.uk"
});
expect(parseDomain("https://user:password@example.co.uk:8080/some/path?and&query#hash")).to.eql({
subdomain: "",
domain: "example",
tld: "co.uk"
});
expect(parseDomain("unknown.tld.kk")).to.equal(null);
expect(parseDomain("invalid url")).to.equal(null);
expect(parseDomain({})).to.equal(null);
Setup
API
parseDomain(url: String): ParsedDomain|null
Returns null
if url
has an unknown tld or if it's not a valid url.
ParsedDomain
{
tld: String,
domain: String,
subdomain: String
}
License
Unlicense