1.1.6 • Published 4 years ago

@browserpass/url v1.1.6

Weekly downloads
8
License
ISC
Repository
github
Last release
4 years ago

BrowserpassURL

This package is an extension of the built-in URL class, which adds some additional properties based on the domain.

The TLD list used by this module is downloaded from publicsuffix.org when building, if it's older than one day.

Usage

const BrowserpassURL = require("@browserpass/url");
var url = new BrowserpassURL("http://www.example.com/test");

console.log(url.validDomain); // true
console.log(url.tld); // com
console.log(url.domain); // example.com
console.log(url.subdomain); // www
console.log(url.hostname); // www.example.com

// parse a raw hostname (with optional port), rather than a full URL
var urlDomainOnly = BrowserpassURL.parseHost("www.example.com:8080");
console.log(urlDomainOnly);
/* {
 *    hostname: 'www.example.com',
 *    tld: 'com',
 *    domain: 'example.com',
 *    subdomain: 'www',
 *    validDomain: true,
 *    port: '8080'
 * }
 */

Extra Properties

PropertyDescription
validDomainWhether the URL contains a valid, public domain
tldThe public TLD component of the domain
domainThe registered domain root
subdomainThe subdomain portion of the hostname
1.1.6

4 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago