Skip to content
Myr

tweak res.redirect() mount route logic

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 1faba13 · Browse files · 3 files+31 added−8 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+31 added−8 removed

  • tests:+23 added−0 removed
  • other:+8 added−8 removed

3 files+31 added−8 removed

modified:lib/application.js+4 added-4 removed
211 unmodified lines
212213 // mounted an app, invoke the hook214 // and adjust some settings215 if (app) {216 base = this.set('basepath') || this.route;217 if ('/' == base) base = '';218 base = base + (app.set('basepath') || app.route);219 app.set('basepath', base);216 var root = this.get('root') || this.route;217 if ('/' == root) root = '';218 root = root + (app.get('root') || app.route);219 app.set('root', root);220 app.parent = this;221 if (app.__mounted) app.__mounted.call(app, this);222 }223
369 unmodified lines
modified:lib/response.js+4 added-4 removed
422 unmodified lines
423424res.redirect = function(url){425 var app = this.app426 , req = this.req427 , base = app.get('root') || app.route427 , root = app.get('root')428 , head = 'HEAD' == req.method429 , status = 302430 , body;431
4 unmodified lines
436 }437438 // Setup redirect map439 var map = {440 back: req.header('Referrer', base)441 , home: base440 back: req.header('Referrer', root)441 , home: root442 };443444 // Support custom redirect map445 map.__proto__ = app.redirects;
8 unmodified lines
454455 // Relative456 if (!~url.indexOf('://')) {457 // Respect mount-point458 if ('/' != base && 0 != url.indexOf(base)) url = base + url;458 if (0 != url.indexOf(app.route)) url = app.route + url;459460 // Absolute461 var host = req.header('Host')462 , tls = false // TODO: req.secure;
95 unmodified lines
modified:test/res.redirect.js+23 added