follow-redirects
Advanced tools
Comparing version 1.10.0 to 1.11.0
16
index.js
@@ -338,5 +338,4 @@ var url = require("url"); | ||
// Drop the Host header, as the redirect might lead to a different host | ||
if (!this._isRedirect) { | ||
removeMatchingHeaders(/^host$/i, this._options.headers); | ||
} | ||
var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) || | ||
url.parse(this._currentUrl).hostname; | ||
@@ -347,4 +346,10 @@ // Create the redirected request | ||
this._isRedirect = true; | ||
Object.assign(this._options, url.parse(redirectUrl)); | ||
var redirectUrlParts = url.parse(redirectUrl); | ||
Object.assign(this._options, redirectUrlParts); | ||
// Drop the Authorization header if redirecting to another host | ||
if (redirectUrlParts.hostname !== previousHostName) { | ||
removeMatchingHeaders(/^authorization$/i, this._options.headers); | ||
} | ||
// Evaluate the beforeRedirect callback | ||
@@ -470,7 +475,10 @@ if (typeof this._options.beforeRedirect === "function") { | ||
function removeMatchingHeaders(regex, headers) { | ||
var lastValue; | ||
for (var header in headers) { | ||
if (regex.test(header)) { | ||
lastValue = headers[header]; | ||
delete headers[header]; | ||
} | ||
} | ||
return lastValue; | ||
} | ||
@@ -477,0 +485,0 @@ |
{ | ||
"name": "follow-redirects", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "HTTP and HTTPS modules that follow redirects.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23524
448