Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
remove unnecessary debug mode from tests
  • Loading branch information
YanLobat committed Sep 16, 2017
1 parent 732fa5b commit 5b515f1
Show file tree
Hide file tree
Showing 2 changed files with 2,370 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,19 @@ Router.prototype.use = function () {
middleware.forEach(function (m) {
if (m.router) {
m.router.stack.forEach(function (nestedLayer) {
//Need to create new Layer instance to avoid mutating existing one
let temp = new Layer(nestedLayer.path, nestedLayer.methods, nestedLayer.stack, nestedLayer.opts);
if (path) temp.setPrefix(path);
if (router.opts.prefix) temp.setPrefix(router.opts.prefix);

//We need to check if any params exist because they are applicable to every layer in router stack
if (router.params) {
const paramsList = Object.keys(router.params);
paramsList.forEach(param => {
//Apply param to new Layer
temp.param(param, router.params[param]);
});
}
router.stack.push(temp);
});

Expand Down Expand Up @@ -338,7 +348,6 @@ Router.prototype.routes = Router.prototype.middleware = function () {
if (mostSpecificLayer.name) {
ctx._matchedRouteName = mostSpecificLayer.name;
}

layerChain = matchedLayers.reduce(function(memo, layer) {
memo.push(function(ctx, next) {
ctx.captures = layer.captures(path, ctx.captures);
Expand All @@ -347,7 +356,6 @@ Router.prototype.routes = Router.prototype.middleware = function () {
});
return memo.concat(layer.stack);
}, []);

return compose(layerChain)(ctx, next);
};

Expand Down

0 comments on commit 5b515f1

Please sign in to comment.