Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    urlextpublic

    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
    

    Keywords

    none

    install

    npm i urlext

    Downloadsweekly downloads

    17

    version

    1.0.2

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar