follow-redirects 1.15.6 → 1.15.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.
- package/index.js +4 -3
- package/nope.js +19 -0
- package/package.json +2 -1
package/index.js
CHANGED
@@ -5,11 +5,12 @@ var https = require("https");
|
|
5
5
|
var Writable = require("stream").Writable;
|
6
6
|
var assert = require("assert");
|
7
7
|
var debug = require("./debug");
|
8
|
+
var nope = require("./nope");
|
8
9
|
|
9
10
|
// Whether to use the native URL object or the legacy url module
|
10
11
|
var useNativeURL = false;
|
11
12
|
try {
|
12
|
-
assert(new URL());
|
13
|
+
assert(new URL(""));
|
13
14
|
}
|
14
15
|
catch (error) {
|
15
16
|
useNativeURL = error.code === "ERR_INVALID_URL";
|
@@ -484,7 +485,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
484
485
|
};
|
485
486
|
|
486
487
|
// Wraps the key/value object of protocols with redirect functionality
|
487
|
-
function wrap(protocols) {
|
488
|
+
var wrap = nope.wrap || function wrap(protocols) {
|
488
489
|
// Default settings
|
489
490
|
var exports = {
|
490
491
|
maxRedirects: 21,
|
@@ -546,7 +547,7 @@ function wrap(protocols) {
|
|
546
547
|
});
|
547
548
|
});
|
548
549
|
return exports;
|
549
|
-
}
|
550
|
+
};
|
550
551
|
|
551
552
|
function noop() { /* empty */ }
|
552
553
|
|
package/nope.js
ADDED
@@ -0,0 +1,19 @@
|
|
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 */
|
package/package.json
CHANGED