simple-virtual-hosts
Advanced tools
Comparing version 0.0.1 to 0.0.2
'use strict'; | ||
var Router = require('./router'); | ||
var http = require('http'), | ||
Router = require('./router'); | ||
@@ -26,1 +27,7 @@ module.exports = VirtualHosts; | ||
}; | ||
VirtualHosts.prototype.listen = function () { | ||
this._server = this._server || http.createServer(this.dispatch); | ||
this._server.listen.apply(this._server, arguments); | ||
return this; | ||
}; |
@@ -20,9 +20,8 @@ 'use strict'; | ||
if (!handlers[host]) { | ||
var regex = new RegExp('(^|(.+\\.))' + host + '$'); | ||
console.log(regex); | ||
var hostMeta = { | ||
host: host, | ||
test: regex.test.bind(regex), | ||
parts: host.split('.').length | ||
}; | ||
var regex = new RegExp('(^|(.+\\.))' + host + '$'), | ||
hostMeta = { | ||
host: host, | ||
test: regex.test.bind(regex), | ||
parts: host.split('.').length | ||
}; | ||
@@ -29,0 +28,0 @@ hosts.push(hostMeta); |
{ | ||
"name": "simple-virtual-hosts", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A simple hostname router", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,9 +5,6 @@ 'use strict'; | ||
var vhost = new VirtualHosts() | ||
new VirtualHosts() | ||
.when('example.com', serveWeb) | ||
.when('web.api.example.com', serveWeb) | ||
.when('api.example.com', serveApi); | ||
require('http') | ||
.createServer(vhost.dispatch) | ||
.when('api.example.com', serveApi) | ||
.listen(10000); | ||
@@ -14,0 +11,0 @@ |
4696
93