Skip to content

Instantly share code, notes, and snippets.

@e7h4n
Created June 21, 2014 03:09
Show Gist options
  • Save e7h4n/94afa56f1a1cd020c7e8 to your computer and use it in GitHub Desktop.
Save e7h4n/94afa56f1a1cd020c7e8 to your computer and use it in GitHub Desktop.
var ignoreRegexp = ['/^\\/?(?=/|$)/i', '/^(.*)\\/?$/i', '/^\\/ss\\/?(?=/|$)/i'];
var routerProto = express.Router().__proto__;
var regexpList = app._router.stack.reduce(function findProto(memo, curr) {
if (ignoreRegexp.indexOf(curr.regexp.toString()) === -1) {
memo.push(curr.regexp);
}
if (curr.handle.__proto__ === routerProto && curr.handle.stack) {
memo = curr.handle.stack.reduce(findProto, memo);
}
return memo;
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment