Skip to content
Myr

Removed `app.redirect()`

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 0f72ca8 · Browse files · 3 files+1 added−100 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+1 added−100 removed

  • tests:+0 added−47 removed
  • other:+1 added−53 removed

3 files+1 added−100 removed

modified:lib/application.js-15 removed
41 unmodified lines
42 var self = this;43 this.cache = {};44 this.settings = {};45 this.engines = {};46 this.redirects = {};46 this.isCallbacks = {};47 this.viewCallbacks = [];48 this.defaultConfiguration();49
357 unmodified lines
407 return this.set(setting, false);408};409410/**412 * Redirect `key` to `url`.413 *414 * @param {String} key415 * @param {String} url416 * @return {app} for chaining417 * @api public418 */419420app.redirect = function(key, url){421 this.redirects[key] = url;422 return this;423};424425/**411 * Configure callback for zero or more envs,412 * when no env is specified that callback will413 * be invoked for all environments. Any combination414 * can be used multiple times, in any order desired.
143 unmodified lines
modified:lib/response.js+1 added-38 removed
443 unmodified lines
444 * While the leading slash would result in a redirect to "/login":445 *446 * res.redirect('/login');447 *448 * Redirect Mapping:449 * 450 * To extend the redirect mapping capabilities that Express provides,451 * we may use the `app.redirect()` method:452 * 453 * app.redirect('google', 'http://google.com');454 * 455 * Now in a route we may call:456 *457 * res.redirect('google');458 *459 * We may also map dynamic redirects:460 *461 * app.redirect('comments', function(req, res){462 * return '/post/' + req.params.id + '/comments';463 * });464 *465 * So now we may do the following, and the redirect will dynamically adjust to466 * the context of the request. If we called this route with _GET /post/12_ our467 * redirect _Location_ would be _/post/12/comments_.468 *469 * app.get('/post/:id', function(req, res){470 * res.redirect('comments');471 * });472 *473 * Unless an absolute `url` is given, the app's mount-point474 * will be respected. For example if we redirect to `/posts`,475 * and our app is mounted at `/blog` we will redirect to `/blog/posts`.476 *448 * @param {String} url449 * @param {Number} code450 * @api public451 */
17 unmodified lines
469 back: req.header('Referrer', root)470 , home: root471 };472502 // support custom redirect map503 map.__proto__ = app.redirects;504505 // attempt mapped redirect506 var mapped = 'function' == typeof map[url]507 ? map[url](req, this)508 : map[url];509473 // perform redirect511 url = mapped || url;474 url = map[url] || url;475476 // relative477 if (!~url.indexOf('://')) {478 var path = app.path();
101 unmodified lines
deleted:test/app.redirect.js-47 removed