Skip to content

Commit

Permalink
Fix FQDN mounting with multiple handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
bmancini55 committed Oct 26, 2013
1 parent d194eca commit 11ced0a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ app.handle = function(req, res, out) {
, slashAdded = false
, index = 0;

req.url = req.url.substr(protohost.length);

function next(err) {
var layer, path, c;

Expand All @@ -118,7 +116,7 @@ app.handle = function(req, res, out) {
slashAdded = false;
}

req.url = protohost + removed + req.url;
req.url = removed + req.url;
req.originalUrl = req.originalUrl || req.url;
removed = '';

Expand Down
16 changes: 16 additions & 0 deletions test/mounting.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ describe('app.use()', function(){
.expect('http://example.com/post/1', done);
})

it('should adjust FQDN req.url with multiple handlers', function(done){
var app = connect();

app.use(function(req,res,next) {
next();
});

app.use('/blog', function(req, res){
res.end(req.url);
});

app.request()
.get('http://example.com/blog/post/1')
.expect('http://example.com/post/1', done);
})

it('should strip trailing slash', function(done){
var blog = connect();

Expand Down

0 comments on commit 11ced0a

Please sign in to comment.