connect-http-please
Advanced tools
28
index.js
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
@@ -36,10 +36,26 @@ var REDIRECT_STATUS_CODES, https, | ||
handleRedirect = function(statusCode) { | ||
var identicalLocation, location, redirectReq, redirectStatusCode, requestOptions; | ||
var headers, identicalLocation, location, redirectReq, redirectStatusCode, requestOptions; | ||
res.writeHead = res.end = function() {}; | ||
redirectStatusCode = __indexOf.call(REDIRECT_STATUS_CODES, statusCode) >= 0; | ||
location = res.getHeader('location'); | ||
identicalLocation = (location != null ? location.indexOf('https://' + req.headers.host + req.url) : void 0) === 0; | ||
if (!(redirectStatusCode && identicalLocation)) { | ||
if (!redirectStatusCode) { | ||
return false; | ||
} | ||
switch (arguments.length) { | ||
case 3: | ||
headers = arguments[2]; | ||
break; | ||
case 2: | ||
headers = arguments[1]; | ||
break; | ||
default: | ||
headers = null; | ||
} | ||
location = (headers != null ? headers.location : void 0) || res.getHeader('location'); | ||
if (!location) { | ||
return false; | ||
} | ||
identicalLocation = location.indexOf('https://' + req.headers.host + req.url) === 0; | ||
if (!identicalLocation) { | ||
return false; | ||
} | ||
console.verbose("HTTPlease: follow redirect to", location.yellow); | ||
@@ -66,3 +82,3 @@ req.headers.host = options.host || options.replaceHost(req.headers.host); | ||
res.writeHead = function() { | ||
if (!handleRedirect(arguments[0])) { | ||
if (!handleRedirect.apply(this, arguments)) { | ||
restore(); | ||
@@ -69,0 +85,0 @@ return writeHead.apply(res, arguments); |
{ | ||
"name": "connect-http-please", | ||
"description": "Follow redirects to https transparently and deliver them via http", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -13,4 +13,4 @@ "type": "git", | ||
"watch": "coffee --watch --compile index.coffee", | ||
"test": "mocha --compilers coffee:coffee-script/register --reporter spec specs/**", | ||
"test-watch": "mocha --watch --compilers coffee:coffee-script/register --reporter spec specs/**" | ||
"test": "mocha --compilers coffee:coffee-script/register --reporter spec specs/*.spec.coffee", | ||
"test-watch": "mocha --watch --compilers coffee:coffee-script/register --reporter spec specs/*.spec.coffee" | ||
}, | ||
@@ -17,0 +17,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
30856
11.2%17
13.33%91
21.33%1
-50%