Skip to content
Myr

This works as expected, and has limited scope.

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

authored by Michael Ahlers · committed by Michael Ahlers · parent d874476 · Browse files · 1 file+19 added−9 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+19 added−9 removed

  • other:+19 added−9 removed

1 file+19 added−9 removed

modified:lib/response.js+19 added-9 removed
632 unmodified lines
633 url = map[url] || url;634635 // relative636 if (!~url.indexOf('://') && 0 != url.indexOf('//')) {637 /*638 * Allows relative redirects for applications mounted at multiple paths by639 * relying on the request (which can be safely assumed is valid since it640 * been satisfied) path, rather than the path "baked in" to the instance.641 */642 //var path = app.path();643 var path = req.originalUrl.split('?')[0]637 var path638639 // relative to path640 if ('.' == url[0]) {641 /*642 * Originally, req.path was used, which is rooted within the643 * application's mount point path. In these mounted applications,644 * relative redirects would fail. For example, for an application645 * nested at /foo/bear/leaf, a redirect to ./baz would result in a646 * redirect to //./baz (which most browsers will interpret as a protocol647 * token). Even if we collapse the redundant slashes, this would still648 * compute the URL as /./baz for a relative redirect within649 * /foo/bear/leaf. This comes with a few advantages, one being that650 * applications may now be mounted at several paths, and relative651 * redirects will work provided they use dotted notation. Additionally,652 * no other behaviors are affected by this change--we are only expanding653 * the functional scope of this method.654 */655 path = req.originalUrl.split('?')[0]647 url = req.path + '/' + url;648 // relative to mount-point656 url = path + ('/' == path[path.length - 1] ? '' : '/') + url;657 // relative to mount-point658 } else if ('/' != url[0]) {659 path = app.path();660 url = path + '/' + url;661 }662 }663
107 unmodified lines