http-base: remove useless asserts and loops.

This commit is contained in:
Christopher Jeffrey 2017-01-11 23:39:51 -08:00
parent 0b296a1a6f
commit c28589d0e6
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -287,12 +287,6 @@ HTTPBase.prototype.use = function use(path, callback, ctx) {
path = null;
}
if (Array.isArray(path)) {
for (i = 0; i < path.length; i++)
this.use(path[i], callback, ctx);
return;
}
this.stack.push(new Route(ctx, path, callback));
};
@ -303,17 +297,6 @@ HTTPBase.prototype.use = function use(path, callback, ctx) {
*/
HTTPBase.prototype.get = function get(path, callback, ctx) {
var i;
if (Array.isArray(path)) {
for (i = 0; i < path.length; i++)
this.get(path[i], callback, ctx);
return;
}
assert(typeof path === 'string');
assert(path.length > 0);
this.routes.get.push(new Route(ctx, path, callback));
};
@ -324,17 +307,6 @@ HTTPBase.prototype.get = function get(path, callback, ctx) {
*/
HTTPBase.prototype.post = function post(path, callback, ctx) {
var i;
if (Array.isArray(path)) {
for (i = 0; i < path.length; i++)
this.post(path[i], callback, ctx);
return;
}
assert(typeof path === 'string');
assert(path.length > 0);
this.routes.post.push(new Route(ctx, path, callback));
};
@ -345,17 +317,6 @@ HTTPBase.prototype.post = function post(path, callback, ctx) {
*/
HTTPBase.prototype.put = function put(path, callback, ctx) {
var i;
if (Array.isArray(path)) {
for (i = 0; i < path.length; i++)
this.put(path[i], callback, ctx);
return;
}
assert(typeof path === 'string');
assert(path.length > 0);
this.routes.put.push(new Route(ctx, path, callback));
};
@ -366,17 +327,6 @@ HTTPBase.prototype.put = function put(path, callback, ctx) {
*/
HTTPBase.prototype.del = function del(path, callback, ctx) {
var i;
if (Array.isArray(path)) {
for (i = 0; i < path.length; i++)
this.del(path[i], callback, ctx);
return;
}
assert(typeof path === 'string');
assert(path.length > 0);
this.routes.del.push(new Route(ctx, path, callback));
};
@ -441,6 +391,7 @@ function Route(ctx, path, callback) {
this.regex = path;
} else {
assert(typeof path === 'string');
assert(path.length > 0);
this.path = path;
}
}
@ -477,10 +428,10 @@ Route.prototype.compile = function compile() {
Route.prototype.match = function match(pathname) {
var match;
assert(this.path);
this.compile();
assert(this.regex);
match = this.regex.exec(pathname);
if (!match)