Skip to content

Commit

Permalink
Merge pull request senchalabs#940 from dougwilson/fix/url-search-fqdn
Browse files Browse the repository at this point in the history
Fix mounted path splitting to ignore search part
  • Loading branch information
jonathanong committed Oct 22, 2013
2 parents 5bdf282 + 3e2e563 commit 8e89649
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ app.use = function(route, fn){

app.handle = function(req, res, out) {
var stack = this.stack
, fqdn = 1 + req.url.indexOf('://')
, search = 1 + req.url.indexOf('?')
, pathlength = search ? search - 1 : req.url.length
, fqdn = 1 + req.url.substr(0, pathlength).indexOf('://')
, protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : ''
, removed = ''
, slashAdded = false
Expand Down
12 changes: 12 additions & 0 deletions test/mounting.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ describe('app.use()', function(){
.expect('/post/1', done);
})

it('should ignore FQDN in search', function (done) {
var app = connect();

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

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

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

Expand Down

0 comments on commit 8e89649

Please sign in to comment.