forked from svrjs/svrjs
Fix wwwredirect function
This commit is contained in:
parent
52e729f51d
commit
1e165dcc58
1 changed files with 2 additions and 2 deletions
4
svr.js
4
svr.js
|
@ -1698,7 +1698,6 @@ function sha256(s) {
|
||||||
hash.update(s);
|
hash.update(s);
|
||||||
return hash.digest("hex");
|
return hash.digest("hex");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var chrsz = 8;
|
var chrsz = 8;
|
||||||
var hexcase = 0;
|
var hexcase = 0;
|
||||||
|
|
||||||
|
@ -4223,12 +4222,13 @@ if (!cluster.isPrimary) {
|
||||||
|
|
||||||
// Handle redirects to addresses with "www." prefix
|
// Handle redirects to addresses with "www." prefix
|
||||||
if (wwwredirect) {
|
if (wwwredirect) {
|
||||||
var hostname = req.headers.host.split[":"];
|
var hostname = req.headers.host.split(":");
|
||||||
var hostport = null;
|
var hostport = null;
|
||||||
if (hostname.length > 1 && (hostname[0] != "[" || hostname[hostname.length - 1] != "]")) hostport = hostname.pop();
|
if (hostname.length > 1 && (hostname[0] != "[" || hostname[hostname.length - 1] != "]")) hostport = hostname.pop();
|
||||||
hostname = hostname.join(":");
|
hostname = hostname.join(":");
|
||||||
if (hostname == domain && hostname.indexOf("www.") != 0) {
|
if (hostname == domain && hostname.indexOf("www.") != 0) {
|
||||||
redirect((req.socket.encrypted ? "https" : "http") + "://www." + hostname + (hostport ? ":" + hostport : "") + req.url.replace(/\/+/g, "/"));
|
redirect((req.socket.encrypted ? "https" : "http") + "://www." + hostname + (hostport ? ":" + hostport : "") + req.url.replace(/\/+/g, "/"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue