redirect-ssl
Advanced tools
Comparing version 1.2.1 to 1.3.0
14
index.js
@@ -19,8 +19,10 @@ const isHTTPS = require('is-https') | ||
return function redirectSSL(req, res, next) { | ||
const _isHttps = isHTTPS(req, xForwardedProto) | ||
const shouldRedirect = _isHttps === false || (redirectUnknown && _isHttps === null) && redirect | ||
if (shouldRedirect) { | ||
const ـredirectURL = 'https://' + (redirectHost || req.headers.host) + _port + req.url | ||
res.writeHead(statusCode, { Location: ـredirectURL }) | ||
return res.end() | ||
if (redirect) { | ||
const _isHttps = isHTTPS(req, xForwardedProto) | ||
const shouldRedirect = _isHttps === false || (redirectUnknown && _isHttps === null) | ||
if (shouldRedirect) { | ||
const ـredirectURL = 'https://' + (redirectHost || req.headers.host) + _port + req.url | ||
res.writeHead(statusCode, { Location: ـredirectURL }) | ||
return res.end() | ||
} | ||
} | ||
@@ -27,0 +29,0 @@ |
{ | ||
"name": "redirect-ssl", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Connect middleware to enforce https", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
7976
5
33