misc fixes.
This commit is contained in:
parent
1ced7af7b4
commit
5923726e78
@ -256,34 +256,35 @@ HTTPServer.prototype._initRouter = function _initRouter() {
|
|||||||
return done(new Error('No routes found.'));
|
return done(new Error('No routes found.'));
|
||||||
|
|
||||||
(function next() {
|
(function next() {
|
||||||
|
var route, path, callback, compiled, matched;
|
||||||
|
|
||||||
|
if (i === routes.length)
|
||||||
|
return done(new Error('Route not found.'));
|
||||||
|
|
||||||
|
route = routes[i++];
|
||||||
|
path = route.path;
|
||||||
|
callback = route.callback;
|
||||||
|
|
||||||
|
if (!route.regex) {
|
||||||
|
compiled = compilePath(path);
|
||||||
|
route.regex = compiled.regex;
|
||||||
|
route.map = compiled.map;
|
||||||
|
}
|
||||||
|
|
||||||
|
matched = route.regex.exec(req.pathname);
|
||||||
|
|
||||||
|
if (!matched)
|
||||||
|
return next();
|
||||||
|
|
||||||
|
req.params = {};
|
||||||
|
matched.slice(1).forEach(function(item, i) {
|
||||||
|
if (route.map[i])
|
||||||
|
req.params[route.map[i]] = item;
|
||||||
|
req.params[i] = item;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Avoid stack overflows
|
||||||
utils.nextTick(function() {
|
utils.nextTick(function() {
|
||||||
var route, path, callback, compiled, matched;
|
|
||||||
|
|
||||||
if (i === routes.length)
|
|
||||||
return done(new Error('Route not found.'));
|
|
||||||
|
|
||||||
route = routes[i++];
|
|
||||||
path = route.path;
|
|
||||||
callback = route.callback;
|
|
||||||
|
|
||||||
if (!route.regex) {
|
|
||||||
compiled = compilePath(path);
|
|
||||||
route.regex = compiled.regex;
|
|
||||||
route.map = compiled.map;
|
|
||||||
}
|
|
||||||
|
|
||||||
matched = route.regex.exec(req.pathname);
|
|
||||||
|
|
||||||
if (!matched)
|
|
||||||
return next();
|
|
||||||
|
|
||||||
req.params = {};
|
|
||||||
matched.slice(1).forEach(function(item, i) {
|
|
||||||
if (route.map[i])
|
|
||||||
req.params[route.map[i]] = item;
|
|
||||||
req.params[i] = item;
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
callback(req, res, next, _send);
|
callback(req, res, next, _send);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -1421,7 +1421,11 @@ utils.ccmp = function(a, b) {
|
|||||||
var res = 0;
|
var res = 0;
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
assert(a.length === b.length);
|
assert(Buffer.isBuffer(a));
|
||||||
|
assert(Buffer.isBuffer(b));
|
||||||
|
|
||||||
|
if (a.length !== b.length)
|
||||||
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < a.length; i++)
|
for (i = 0; i < a.length; i++)
|
||||||
res |= a[i] ^ b[i];
|
res |= a[i] ^ b[i];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user