controller
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -165,4 +165,12 @@ var isRegExp = require('util').isRegExp; | ||
var self = this; | ||
//clear old anonymous middlewares if we're overwriting | ||
if (this.actions[name]) { | ||
self.middlewares.forEach(function(middleware) { | ||
if (middleware.anonymous && middleware.scope[0] == name) | ||
self.middlewares = _.without(self.middlewares, middleware); | ||
}); | ||
} | ||
groups = groups.filter(function(group) { | ||
if (typeof group == "function") { | ||
group.anonymous = true; | ||
self.use(name, group); | ||
@@ -169,0 +177,0 @@ return false; |
{ | ||
"name": "controller", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "an action controller for express", | ||
@@ -5,0 +5,0 @@ "main": "lib/controller.js", |
@@ -197,2 +197,14 @@ var assert = require('assert'); | ||
}); | ||
it('should override ungrouped middleware', function(done) { | ||
var c = ctrl(); | ||
c.define('action', [makemw('thingmw')], routestr('thing')); | ||
c.define('action', [makemw('thingmw2')], routestr('thing')); | ||
c.route('get', '/action', 'action'); | ||
req(express().use(c)) | ||
.get('/action') | ||
.expect(200) | ||
.expect('thingmw2') | ||
.end(done); | ||
}); | ||
it('should apply grouped middleware with use()', function(done) { | ||
@@ -199,0 +211,0 @@ var c = ctrl(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28952
512