This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function vhostof(req, regexp) { | |
| var host = req.headers.host | |
| var hostname = hostnameof(req) | |
| if (!hostname) { | |
| return | |
| } | |
| var match = regexp.exec(hostname) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isregexp(val) { | |
| return Object.prototype.toString.call(val) === '[object RegExp]' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var asteriskRegExp = /\*/g | |
| var asteriskReplace = '([^\.]+)' | |
| var endAnchoredRegExp = /(?:^|[^\\])(?:\\\\)*\$$/ | |
| var escapeRegExp = /([.+?^=!:${}()|\[\]\/\\])/g | |
| var escapeReplace = '\\$1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const app = express(); | |
| const vhost = require('vhost'); | |
| // after registering all middleware, then you register your hostname as | |
| app.use(vhost('admin.localhost',app)); |
NewerOlder