From 2f2a652bc9420f2d05ddfe914048cfe5c327d7c7 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Tue, 26 Nov 2013 13:11:15 -0600 Subject: [PATCH] fixes #1826: res.redirect('toString') fails with 500 Removed the unused map and corrected the doc comment. --- lib/response.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/response.js b/lib/response.js index e160c06a..25c49eed 100644 --- a/lib/response.js +++ b/lib/response.js @@ -605,8 +605,7 @@ res.cookie = function(name, val, options){ /** * Set the location header to `url`. * - * The given `url` can also be the name of a mapped url, for - * example by default express supports "back" which redirects + * The given `url` can also be "back", which redirects * to the _Referrer_ or _Referer_ headers or "/". * * Examples: @@ -637,11 +636,8 @@ res.location = function(url){ , req = this.req , path; - // setup redirect map - var map = { back: req.get('Referrer') || '/' }; - - // perform redirect - url = map[url] || url; + // "back" is an alias for the referrer + if(url === 'back') url = req.get('Referrer') || '/'; // relative if (!~url.indexOf('://') && 0 != url.indexOf('//')) { -- 2.11.4.GIT