Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Update /bin/bouncy.js to support wildcard characters (*) for sub-domains... #29

wants to merge 1 commit into from

4 participants


I believe the added algorithm at line 16 would allow for "*" routes to be matched by "", "", etc.


I bet there is a wildcard module somewhere that has a more robust and well-tested recursive algorithm for this. Or perhaps fall into regex mode if the first and last characters in the key are '/'.


Could maybe do both. A regex syntax would be great for real advanced pattern matching. While a simple wildcard syntax would be great too for the regular matching.

I've tested the changes with "". It matches "" and "". I've also tried "" which matches "" and "", but not "". You should try it out as well.


This would be a nice feature! Like I have it go to my WordPress Network install, so for each new subdomain, I have to add to the routes.json file.


I think isaacs minimatch module would be a good fit for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 1 deletion.
  1. +9 −1 bin/bouncy.js
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 = ( || '').replace(/:\d+$/, '');
- var route = config[host] || config[''];
+ for (var i in config)
+ {
+ var pattern = '^'+i.replace(/\*\./g, '(\\w*\\.)*').replace(/\\?\./g, '\\.');
+ if ( != -1)
+ {
+ var route = config[i];
+ break;
+ }
+ }
if (Array.isArray(route)) {
// jump to a random route on arrays
Something went wrong with that request. Please try again.