follow-redirects 1.14.7 → 1.14.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of follow-redirects might be problematic. Click here for more details.
- package/index.js +7 -3
- package/package.json +1 -1
package/index.js
CHANGED
@@ -392,8 +392,9 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
392
392
|
var redirectUrlParts = url.parse(redirectUrl);
|
393
393
|
Object.assign(this._options, redirectUrlParts);
|
394
394
|
|
395
|
-
// Drop
|
396
|
-
if (
|
395
|
+
// Drop confidential headers when redirecting to another scheme:domain
|
396
|
+
if (redirectUrlParts.protocol !== currentUrlParts.protocol ||
|
397
|
+
!isSameOrSubdomain(redirectUrlParts.host, currentHost)) {
|
397
398
|
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
398
399
|
}
|
399
400
|
|
@@ -559,7 +560,10 @@ function abortRequest(request) {
|
|
559
560
|
request.abort();
|
560
561
|
}
|
561
562
|
|
562
|
-
function
|
563
|
+
function isSameOrSubdomain(subdomain, domain) {
|
564
|
+
if (subdomain === domain) {
|
565
|
+
return true;
|
566
|
+
}
|
563
567
|
const dot = subdomain.length - domain.length - 1;
|
564
568
|
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
565
569
|
}
|