Skip to content
Myr

Fix handling of URLs containing :// in the path

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fixes #2421

authored by Aria Stewart · committed by Douglas Christopher Wilson · parent d40dc65 · Browse files · 3 files+23 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+23 added−1 removed

  • tests:+17 added−0 removed
  • other:+6 added−1 removed

3 files+23 added−1 removed

modified:lib/router/index.js+1 added-1 removed
124 unmodified lines
125 debug('dispatching %s %s', req.method, req.url);126127 var search = 1 + req.url.indexOf('?');128 var pathlength = search ? search - 1 : req.url.length;129 var fqdn = 1 + req.url.substr(0, pathlength).indexOf('://');129 var fqdn = req.url[0] !== '/' && 1 + req.url.substr(0, pathlength).indexOf('://');130 var protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : '';131 var idx = 0;132 var removed = '';133 var slashAdded = false;
442 unmodified lines
modified:test/Router.js+17 added
217 unmodified lines
218 done();219 });220 });221222 it('should ignore FQDN in path', function (done) {223 var request = { hit: 0, url: '/proxy/http://example.com/blog/post/1', method: 'GET' };224 var router = new Router();225226 router.use('/proxy', function (req, res, next) {227 assert.equal(req.hit++, 0);228 assert.equal(req.url, '/http://example.com/blog/post/1');229 next();230 });231232 router.handle(request, {}, function (err) {233 if (err) return done(err);234 assert.equal(request.hit, 1);235 done();236 });237 });238239 it('should adjust FQDN req.url', function (done) {240 var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' };241 var router = new Router();242
248 unmodified lines
modified:History.md+5 added
1unreleased2==========34 * Fix handling of URLs containing `://` in the path564.10.0 / 2014-10-237===================89 * Add support for `app.set('views', array)`
2431 unmodified lines