urlext

1.0.2 • Public • Published

URL Toolbelt Build Status

A set of libraries to extract specific metrics, states and data about a URL.

Installation

npm install urlext

Usage

var urlext = require('urlext');

Then get url metrics for www.cnn.com by calling (the port identifier :80 is optional, but shown here for completeness):

urlext.extract('www.cnn.com:80', function (err, res) {
  console.log(JSON.stringify(res));
});

or

urlext.extract('http://www.cnn.com:80', function (err, res) {
  console.log(JSON.stringify(res));
});

Will provide following output:

{
  "href": "http://www.cnn.com",
  "hostname": "www.cnn.com",
  "port": 80,
  "pathname": "/",
  "domain": "cnn",
  "tld": [
    "com"
  ],
  "subdomain": [
    "www"
  ],
  "responseTime": 1316,
  "response": {
    "error": null,
    "code": 200,
    "redirects": [
      {
        "statusCode": 302,
        "redirectUri": "http://edition.cnn.com/"
      }
    ]
  }
}

TLDs

The tld, domain and subdomain fields in the result are extracted based on the tld list provided by PublixSuffix.org.

Test

To run the test-suite execute:

npm test

Readme

Keywords

none

Package Sidebar

Install

npm i urlext

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • ndemoor