follow-redirects 1.2.3 → 1.2.4

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 +13 -2
  2. package/package.json +4 -1
package/index.js CHANGED
@@ -42,6 +42,17 @@ function RedirectableRequest(options, responseCallback) {
42
42
  self._processResponse(response);
43
43
  };
44
44
 
45
+ // Complete the URL object when necessary
46
+ if (!options.pathname && options.path) {
47
+ var searchPos = options.path.indexOf('?');
48
+ if (searchPos < 0) {
49
+ options.pathname = options.path;
50
+ } else {
51
+ options.pathname = options.path.substring(0, searchPos);
52
+ options.search = options.path.substring(searchPos);
53
+ }
54
+ }
55
+
45
56
  // Perform the first request
46
57
  this._performRequest();
47
58
  }
@@ -57,7 +68,7 @@ RedirectableRequest.prototype._performRequest = function () {
57
68
  }
58
69
 
59
70
  // Create the native request
60
- var nativeProtocol = nativeProtocols[this._options.protocol];
71
+ var nativeProtocol = nativeProtocols[protocol];
61
72
  var request = this._currentRequest =
62
73
  nativeProtocol.request(this._options, this._onNativeResponse);
63
74
  this._currentUrl = url.format(this._options);
@@ -182,7 +193,7 @@ RedirectableRequest.prototype.setTimeout = function (timeout, callback) {
182
193
  };
183
194
 
184
195
  // Writes buffered data to the current native request
185
- RedirectableRequest.prototype._write = function (data, encoding, callback) {
196
+ RedirectableRequest.prototype.write = function (data, encoding, callback) {
186
197
  this._currentRequest.write(data, encoding, callback);
187
198
  this._bufferedWrites.push({data: data, encoding: encoding});
188
199
  };
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "follow-redirects",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "HTTP and HTTPS modules that follow redirects.",
5
5
  "main": "index.js",
6
+ "engines": {
7
+ "node": ">=4.0"
8
+ },
6
9
  "scripts": {
7
10
  "test": "xo && BLUEBIRD_DEBUG=1 nyc mocha"
8
11
  },