Skip to content
Myr

add backwards compat for res.redirect() status. Closes #1336

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 496ee40 · Browse files · 2 files+26 added−3 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+26 added−3 removed

  • tests:+19 added−1 removed
  • other:+7 added−2 removed

2 files+26 added−3 removed

modified:lib/response.js+7 added-2 removed
594 unmodified lines
595 *596 * res.redirect('/foo/bar');597 * res.redirect('http://example.com');598 * res.redirect(301, 'http://example.com');599 * res.redirect('http://example.com', 301);600 * res.redirect('../login'); // /blog/post/1 -> /blog/login601 *602 * Mounting:603 *
21 unmodified lines
625 , body;626627 // allow status / url628 if (2 == arguments.length) {629 if ('number' == typeof url) {628 status = url;629 url = arguments[1];630 status = url;631 url = arguments[1];632 } else {633 status = arguments[1];634 }635 }636637 // setup redirect map638 var map = { back: req.get('Referrer') || '/' };
83 unmodified lines
modified:test/res.redirect.js+19 added-1 removed
194 unmodified lines
195 done();196 })197 })198 })199 199200 describe('.redirect(url, status)', function(){201 it('should set the response status', function(done){202 var app = express();203204 app.use(function(req, res){205 res.redirect('http://google.com', 303);206 });207208 request(app)209 .get('/')210 .end(function(err, res){211 res.statusCode.should.equal(303);212 res.headers.should.have.property('location', 'http://google.com');213 done();214 })215 })216 })217218 describe('when the request method is HEAD', function(){219 it('should ignore the body', function(done){220 var app = express();221
92 unmodified lines