expressjs-domain-parser
v0.0.8
Published
A domain/url parser that breaks apart into components
Downloads
5
Maintainers
Readme
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
);