Browse files

Update /bin/bouncy.js to support wildcard characters (*) for sub-doma…

…ins.
  • Loading branch information...
1 parent 31e425d commit 0c24383a26133b0347400203501c21f9a0aa0874 @samholmes committed Mar 27, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 bin/bouncy.js
View
10 bin/bouncy.js
@@ -13,7 +13,15 @@ var config = JSON.parse(fs.readFileSync(configFile));
var bouncy = require('bouncy');
bouncy(function (req, bounce) {
var host = (req.headers.host || '').replace(/:\d+$/, '');
- var route = config[host] || config[''];
+ for (var i in config)
+ {
+ var pattern = '^'+i.replace(/\*\./g, '(\\w*\\.)*').replace(/\\?\./g, '\\.');
+ if (host.search(pattern) != -1)
+ {
+ var route = config[i];
+ break;
+ }
+ }
if (Array.isArray(route)) {
// jump to a random route on arrays

0 comments on commit 0c24383

Please sign in to comment.