Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b5d3c39
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
/*! | ||
* express-subdomains | ||
* Copyright(c) Thomas Blobaum | ||
* MIT Licensed | ||
*/ | ||
|
||
var subs = [] | ||
|
||
module.exports = { | ||
use: function (base, options) { | ||
options = options || {} | ||
subs.push({ | ||
base:base, | ||
options:options | ||
}) | ||
}, | ||
middleware: function (req, res, next) { | ||
subs.forEach(function(subdomain) { | ||
if (subdomain.base.test(req.headers.host)) { | ||
req.url = '/' + subdomain.base + req.url | ||
return next() | ||
} | ||
}) | ||
return next() | ||
} | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"author": "Thomas Blobaum <tblobaum@gmail.com> (https://github.com/tblobaum)", | ||
"name": "express-subdomains", | ||
"description": "subdomain support for express", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/tblobaum/express-subdomains", | ||
"repository": { | ||
"url": "" | ||
}, | ||
"scripts": { | ||
"test": "npm test" | ||
}, | ||
"engines": { | ||
"node": "~0.6.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
} |