Skip to content

Commit

Permalink
misc refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jun 27, 2011
1 parent 1f0e7a8 commit a54aac8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ Server.prototype.handle = function(req, res, out) {
, index = 0;

function next(err) {
var layer, path, c;
req.url = removed + req.url;
req.originalUrl = req.originalUrl || req.url;
removed = '';

var layer = stack[index++];
layer = stack[index++];

// all done
if (!layer) {
Expand Down Expand Up @@ -176,14 +177,14 @@ Server.prototype.handle = function(req, res, out) {
}

try {
var pathname = parse(req.url).pathname;
if (undefined == pathname) pathname = '/';
path = parse(req.url).pathname;
if (undefined == path) path = '/';

// skip this layer if the route doesn't match.
if (0 != pathname.indexOf(layer.route)) return next(err);
if (0 != path.indexOf(layer.route)) return next(err);

var nextChar = pathname[layer.route.length];
if (nextChar && '/' != nextChar && '.' != nextChar) return next(err);
c = path[layer.route.length];
if (c && '/' != c && '.' != c) return next(err);

// Call the layer handler
// Trim off the part of the url that matches the route
Expand Down

0 comments on commit a54aac8

Please sign in to comment.