@browserpass/url

1.1.6 • Public • Published

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

Property Description
validDomain Whether the URL contains a valid, public domain
tld The public TLD component of the domain
domain The registered domain root
subdomain The subdomain portion of the hostname

Readme

Keywords

none

Package Sidebar

Install

npm i @browserpass/url

Weekly Downloads

11

Version

1.1.6

License

ISC

Unpacked Size

174 kB

Total Files

9

Last publish

Collaborators

  • erayd
  • maximbaz