Skip to content
Myr

Added support for ./ in redirects

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 3212a70 · Browse files · 2 files+23 added−4 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+23 added−4 removed

  • tests:+18 added−0 removed
  • other:+5 added−4 removed

2 files+23 added−4 removed

modified:lib/response.js+5 added-4 removed
471 unmodified lines
472 // relative473 if (!~url.indexOf('://')) {474 var path = app.path();475476 // relative to host477 if ('/' == url[0]) {478476 // relative to path477 if (0 == url.indexOf('./')) {478 path = req.path;479 url = path + '/' + url.slice(2)480 // relative to mount-point480 } else if (1 != url.indexOf(path)) {481 } else if ('/' != url[0]) {482 url = path + '/' + url;483 }484485 // Absolute
91 unmodified lines
modified:test/res.redirect.js+18 added
35 unmodified lines
36 done();37 })38 })39 })4041 describe('with leading ./', function(){42 it('should construct path-relative urls', function(done){43 var app = express();4445 app.use(function(req, res){46 res.redirect('./edit');47 });4849 request(app)50 .get('/post/1')51 .set('Host', 'example.com')52 .end(function(res){53 res.headers.should.have.property('location', 'http://example.com/post/1/edit');54 done();55 })56 })57 })58 59 describe('without leading /', function(){60 it('should construct mount-point relative urls', function(done){61 var app = express();
157 unmodified lines