Commit baa792df authored by Aria Stewart's avatar Aria Stewart Committed by Douglas Christopher Wilson

Fix handling of URLs containing :// in the path

parent 98db5c45
2.x
===
* Fix handling of URLs containing `://` in the path
* deps: body-parser@~1.9.2
- deps: qs@2.3.2
* deps: qs@2.3.2
......
......@@ -103,7 +103,7 @@ app.handle = function(req, res, out) {
var stack = this.stack
, searchIndex = req.url.indexOf('?')
, pathlength = searchIndex !== -1 ? searchIndex : req.url.length
, fqdn = 1 + req.url.substr(0, pathlength).indexOf('://')
, fqdn = req.url[0] !== '/' && 1 + req.url.substr(0, pathlength).indexOf('://')
, protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : ''
, removed = ''
, slashAdded = false
......
......@@ -61,6 +61,18 @@ describe('app.use()', function(){
.expect('/?url=http://example.com/blog/post/1', done);
});
it('should ignore FQDN in path', function (done) {
var app = connect();
app.use('/proxy', function (req, res) {
res.end(req.url);
});
app.request()
.get('/proxy/http://example.com/blog/post/1')
.expect('/http://example.com/blog/post/1', done);
});
it('should adjust FQDN req.url', function(done){
var app = connect();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment