Skip to content

Commit

Permalink
refactored res.redirect() slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 15, 2011
1 parent a3cddb8 commit 6bd5182
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/response.js
Expand Up @@ -14,6 +14,7 @@ var fs = require('fs')
, path = require('path')
, connect = require('connect')
, utils = connect.utils
, statusCodes = http.STATUS_CODES
, parseRange = require('./utils').parseRange
, res = http.ServerResponse.prototype
, send = connect.static.send
Expand Down Expand Up @@ -392,10 +393,10 @@ res.redirect = function(url, status){

// Support text/{plain,html} by default
if (req.accepts('html')) {
body = '<p>' + http.STATUS_CODES[status] + '. Redirecting to <a href="' + url + '">' + url + '</a></p>';
body = '<p>' + statusCodes[status] + '. Redirecting to <a href="' + url + '">' + url + '</a></p>';
this.header('Content-Type', 'text/html');
} else {
body = http.STATUS_CODES[status] + '. Redirecting to ' + url;
body = statusCodes[status] + '. Redirecting to ' + url;
this.header('Content-Type', 'text/plain');
}

Expand Down

0 comments on commit 6bd5182

Please sign in to comment.