Skip to content
Myr

add res.redirect("//foo.com") support

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

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent d66f0e5 · Browse files · 2 files+20 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

2 files+20 added−1 removed

  • tests:+19 added−0 removed
  • other:+1 added−1 removed

2 files+20 added−1 removed

modified:lib/response.js+1 added-1 removed
516 unmodified lines
517 // perform redirect518 url = map[url] || url;519520 // relative521 if (!~url.indexOf('://')) {521 if (!~url.indexOf('://') && 0 != url.indexOf('//')) {522 var path = app.path();523524 // relative to path525 if ('.' == url[0]) {
77 unmodified lines
modified:test/res.redirect.js+19 added
17 unmodified lines
18 res.headers.should.have.property('location', 'http://google.com');19 done();20 })21 })2223 describe('with leading //', function(){24 it('should pass through scheme-relative urls', function(done){25 var app = express();2627 app.use(function(req, res){28 res.redirect('//cuteoverload.com');29 });3031 request(app)32 .get('/')33 .set('Host', 'example.com')34 .end(function(err, res){35 res.headers.should.have.property('location', '//cuteoverload.com');36 done();37 })38 })39 })4041 42 describe('with leading /', function(){43 it('should construct scheme-relative urls', function(done){44 var app = express();
234 unmodified lines