0.0.8 • Published 7 years ago

expressjs-domain-parser v0.0.8

Weekly downloads
12
License
ISC
Repository
github
Last release
7 years ago

expressjs-domain-parser

A domain/url parser that breaks apart into components

About

Install

//npm
npm install expressjs-domain-parser --save

//bower
bower install domain-parser --save

Here is an example on how to use it:

Example

Express middleware

  express = require("express");
  app = express();

  var tdl = require('expressjs-domain-parser');
  app.use(tdl.express);

standalone

  var tdl = require('expressjs-domain-parser');
  var parsed = tdl.parse('http://domainname.com:4080/api/bdd/');

  console.log(
    parsed.domain.url          //> "developer.domainname.org:8080" -- host with port number
    , parsed.domain.sld        //> "domain" -- the second part from the right
    , parsed.domain.idn        //> "developer.domainname.org" -- domain name
    , parsed.domain.protocol   //> "https" -- request type
    , parsed.domain.suffix     //> "org" -- ttd name
    , parsed.domain.prefix     //> "developer" -- specific sub domain
    , parsed.domain.port       //> "8080" -- port number
    , parsed.domain.token      //> "DeveloperDomainnameOrg" -- convert domain into key
    , parsed.domain.level(2)   //> "domainname" -- specific domain level
  );

License

MIT © Carlos Marte

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.1

7 years ago