Skip to content
This repository has been archived by the owner on Sep 13, 2018. It is now read-only.

Commit

Permalink
Update redirect.js
Browse files Browse the repository at this point in the history
  • Loading branch information
csu committed Feb 2, 2016
1 parent af5464e commit bee9829
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/redirect.js
Expand Up @@ -10,20 +10,20 @@ module.exports = function (redirects, port) {
redirect = redirects[requestHost];
}

//if the host is not found in the configuration, we default to the catch all
if(!redirect){
// if the host is not found in the configuration, we default to the catch all
if (!redirect){
redirect = redirects['*'];
}

if(redirect){
if (redirect){
var newUrl = redirect.host + url.parse(req.url).pathname;

res.statusCode = redirect.code || 302;
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Location', newUrl);
res.end('Redirecting to '+newUrl);
}else{
//their is no catch all, we will just show an error message
} else {
// there is no catch all, we will just show an error message
res.statusCode = 404;
res.setHeader('Content-Type', 'text/plain');
res.end('Host not found');
Expand Down

0 comments on commit bee9829

Please sign in to comment.