Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (var j = 0; j < this._nesteds.length; j++) {
if ((ret = this._nesteds[j].match(request))) {
return ret;
}
}
}
// route is not matched
return null;
};
/**
* Define supported HTTP methods for Route object
* and all failback method
*/
if (methods[methods.length - 1] !== 'all') {
methods.push('all');
}
methods.forEach(function (METHOD) {
Route.prototype[METHOD] = function () {
var cbs = Array.prototype.slice.apply(arguments),
that = this;
cbs.forEach(function (cb) {
util.isGenerator(cb, that);
});
this.handlers[METHOD.toUpperCase()] = cbs;
return this;
};
});
Router.prototype._optionsFor = function _optionsFor(path) {
var options = [];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
if (method === 'options') continue;
var routes = this.map[method];
// HEAD methods include GET routes
if (!routes && method === 'head') {
routes = this.map.get;
}
if (!routes) continue;
for (var j = 0; j < routes.length; j++) {
if (routes[j].match(path)) {
options.push(method.toUpperCase());
it('should handle VERBS', function(done) {
var count = 0;
var route = new Route('/foo');
var cb = after(methods.length, function (err) {
if (err) return done(err);
count.should.equal(methods.length);
done();
});
route.all(function(req, res, next) {
count++;
next();
});
methods.forEach(function testMethod(method) {
var req = { method: method, url: '/' };
route.dispatch(req, {}, cb);
});
})
it('registers route specific to HTTP verb', function () {
var app = new Koa();
var router = new Router();
app.use(router.routes());
methods.forEach(function (method) {
router.should.have.property(method);
router[method].should.be.type('function');
router[method]('/', function () {});
});
router.stack.should.have.length(methods.length);
});
it('registers route specific to HTTP verb', function () {
const app = new Koa();
const router = strapi.middlewares.router();
app.use(router.routes());
methods.forEach(function (method) {
router.should.have.property(method);
router[method].should.be.type('function');
router[method]('/', function * () {});
});
router.stack.should.have.length(methods.length);
});
var cb = after(methods.length, function (err) {
if (err) return done(err);
count.should.equal(methods.length);
done();
});
app.all = function all(path) {
this.lazyrouter();
var route = this._router.route(path);
var args = slice.call(arguments, 1);
for (var i = 0; i < methods.length; i++) {
route[methods[i]].apply(route, args);
}
return this;
};
app.all = function all(path) {
this.lazyrouter();
var route = this._router.route(path);
var args = slice.call(arguments, 1);
for (var i = 0; i < methods.length; i++) {
route[methods[i]].apply(route, args);
}
return this;
};
app.all = function all(path) {
this.lazyrouter();
var route = this._router.route(path);
var args = slice.call(arguments, 1);
for (var i = 0; i < methods.length; i++) {
route[methods[i]].apply(route, args);
}
return this;
};
Application.prototype.all = function (path) {
var route = this.route(path);
var args = Array.prototype.call(arguments, 1);
for (var i = 0; i < methods.length; i++) {
route[methods[i]].apply(route, args);
}
return this;
};