urlext

A set of API's to extract specific metrics, states and data about a URL.

npm install urlext
8 downloads in the last week
12 downloads in the last month

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
npm loves you