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.

Files changed (2) hide show
  1. package/index.js +7 -3
  2. 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 the confidential headers when redirecting to another domain
396
- if (!(redirectUrlParts.host === currentHost || isSubdomainOf(redirectUrlParts.host, currentHost))) {
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 isSubdomainOf(subdomain, domain) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "follow-redirects",
3
- "version": "1.14.7",
3
+ "version": "1.14.8",
4
4
  "description": "HTTP and HTTPS modules that follow redirects.",
5
5
  "license": "MIT",
6
6
  "main": "index.js",