follow-redirects 1.15.8 → 1.15.9
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.
- package/index.js +22 -9
- package/package.json +2 -3
- package/nope.js +0 -19
package/index.js
CHANGED
@@ -5,7 +5,17 @@ var https = require("https");
|
|
5
5
|
var Writable = require("stream").Writable;
|
6
6
|
var assert = require("assert");
|
7
7
|
var debug = require("./debug");
|
8
|
-
|
8
|
+
|
9
|
+
// Preventive platform detection
|
10
|
+
// istanbul ignore next
|
11
|
+
(function detectUnsupportedEnvironment() {
|
12
|
+
var looksLikeNode = typeof process !== "undefined";
|
13
|
+
var looksLikeBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
14
|
+
var looksLikeV8 = isFunction(Error.captureStackTrace);
|
15
|
+
if (!looksLikeNode && (looksLikeBrowser || !looksLikeV8)) {
|
16
|
+
console.warn("The follow-redirects package should be excluded from browser builds.");
|
17
|
+
}
|
18
|
+
}());
|
9
19
|
|
10
20
|
// Whether to use the native URL object or the legacy url module
|
11
21
|
var useNativeURL = false;
|
@@ -347,17 +357,17 @@ RedirectableRequest.prototype._performRequest = function () {
|
|
347
357
|
var buffers = this._requestBodyBuffers;
|
348
358
|
(function writeNext(error) {
|
349
359
|
// Only write if this request has not been redirected yet
|
350
|
-
|
360
|
+
// istanbul ignore else
|
351
361
|
if (request === self._currentRequest) {
|
352
362
|
// Report any write errors
|
353
|
-
|
363
|
+
// istanbul ignore if
|
354
364
|
if (error) {
|
355
365
|
self.emit("error", error);
|
356
366
|
}
|
357
367
|
// Write the next buffer if there are still left
|
358
368
|
else if (i < buffers.length) {
|
359
369
|
var buffer = buffers[i++];
|
360
|
-
|
370
|
+
// istanbul ignore else
|
361
371
|
if (!request.finished) {
|
362
372
|
request.write(buffer.data, buffer.encoding, writeNext);
|
363
373
|
}
|
@@ -485,7 +495,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
485
495
|
};
|
486
496
|
|
487
497
|
// Wraps the key/value object of protocols with redirect functionality
|
488
|
-
|
498
|
+
function wrap(protocols) {
|
489
499
|
// Default settings
|
490
500
|
var exports = {
|
491
501
|
maxRedirects: 21,
|
@@ -547,13 +557,13 @@ var wrap = nope.wrap || function wrap(protocols) {
|
|
547
557
|
});
|
548
558
|
});
|
549
559
|
return exports;
|
550
|
-
}
|
560
|
+
}
|
551
561
|
|
552
562
|
function noop() { /* empty */ }
|
553
563
|
|
554
564
|
function parseUrl(input) {
|
555
565
|
var parsed;
|
556
|
-
|
566
|
+
// istanbul ignore else
|
557
567
|
if (useNativeURL) {
|
558
568
|
parsed = new URL(input);
|
559
569
|
}
|
@@ -568,7 +578,7 @@ function parseUrl(input) {
|
|
568
578
|
}
|
569
579
|
|
570
580
|
function resolveUrl(relative, base) {
|
571
|
-
|
581
|
+
// istanbul ignore next
|
572
582
|
return useNativeURL ? new URL(relative, base) : parseUrl(url.resolve(base, relative));
|
573
583
|
}
|
574
584
|
|
@@ -617,7 +627,10 @@ function removeMatchingHeaders(regex, headers) {
|
|
617
627
|
function createErrorType(code, message, baseClass) {
|
618
628
|
// Create constructor
|
619
629
|
function CustomError(properties) {
|
620
|
-
|
630
|
+
// istanbul ignore else
|
631
|
+
if (isFunction(Error.captureStackTrace)) {
|
632
|
+
Error.captureStackTrace(this, this.constructor);
|
633
|
+
}
|
621
634
|
Object.assign(this, properties || {});
|
622
635
|
this.code = code;
|
623
636
|
this.message = this.cause ? message + ": " + this.cause.message : message;
|
package/package.json
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "follow-redirects",
|
3
|
-
"version": "1.15.
|
3
|
+
"version": "1.15.9",
|
4
4
|
"description": "HTTP and HTTPS modules that follow redirects.",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "index.js",
|
7
|
-
"browser": "nope.js",
|
8
7
|
"files": [
|
9
8
|
"*.js"
|
10
9
|
],
|
@@ -17,7 +16,7 @@
|
|
17
16
|
},
|
18
17
|
"repository": {
|
19
18
|
"type": "git",
|
20
|
-
"url": "git@github.com
|
19
|
+
"url": "git+ssh://git@github.com/follow-redirects/follow-redirects.git"
|
21
20
|
},
|
22
21
|
"homepage": "https://github.com/follow-redirects/follow-redirects",
|
23
22
|
"bugs": {
|
package/nope.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
// follow-redirects absolutely must not be used in the browser.
|
2
|
-
// Neither should the `http` and `https` modules it replaces, yet here we are.
|
3
|
-
var http = require("http");
|
4
|
-
var https = require("https");
|
5
|
-
|
6
|
-
// eslint-disable-next-line no-undef
|
7
|
-
var browser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
8
|
-
|
9
|
-
module.exports = {
|
10
|
-
http: http,
|
11
|
-
https: https,
|
12
|
-
wrap: browser && function (module) {
|
13
|
-
// eslint-disable-next-line
|
14
|
-
console.warn("Exclude follow-redirects from browser builds.");
|
15
|
-
return module;
|
16
|
-
},
|
17
|
-
};
|
18
|
-
|
19
|
-
/* istanbul ignore file */
|