Skip to content
Myr

Changed `res.redirect()` signature to accept status first. Closes #832

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

to match the others

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 54c1a20 · Browse files · 1 file+15 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

1 file+15 added−3 removed

  • other:+15 added−3 removed

1 file+15 added−3 removed

modified:lib/response.js+15 added-3 removed
360 unmodified lines
361};362363/**364 * Redirect to the given `url` with optional response `status`365 * defauling to 302.365 * defaulting to 302.366 *367 * The given `url` can also be the name of a mapped url, for368 * example by default express supports "back" which redirects369 * to the _Referrer_ or _Referer_ headers or the application's370 * "basepath" setting. Express also supports "basepath" out of the box,371 * which can be set via `app.set('basepath', '/blog');`.372 *373 * Examples:374 *375 * res.redirect('/foo/bar');376 * res.redirect('http://example.com');377 * res.redirect(301, 'http://example.com');378 *379 * Redirect Mapping:380 * 381 * To extend the redirect mapping capabilities that Express provides,382 * we may use the `app.redirect()` method:
26 unmodified lines
409 * @param {Number} code410 * @api public411 */412407res.redirect = function(url, status){413res.redirect = function(url){414 var app = this.app415 , req = this.req416 , base = app.set('basepath') || app.route411 , status = status || 302417 , head = 'HEAD' == req.method418 , status = 302419 , body;420421 // allow status / url422 if (2 == arguments.length) {423 status = url;424 url = arguments[1];425 }426427 // Setup redirect map428 var map = {429 back: req.header('Referrer', base)430 , home: base
38 unmodified lines