follow-redirects 1.15.6 → 1.15.7

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.
Files changed (3) hide show
  1. package/index.js +8 -0
  2. package/nope.js +20 -0
  3. package/package.json +2 -1
package/index.js CHANGED
@@ -5,6 +5,14 @@ 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");
9
+
10
+ // Disaster prevention
11
+ /* istanbul ignore next */
12
+ if (nope.isBrowser()) {
13
+ module.exports = nope;
14
+ return;
15
+ }
8
16
 
9
17
  // Whether to use the native URL object or the legacy url module
10
18
  var useNativeURL = false;
package/nope.js ADDED
@@ -0,0 +1,20 @@
1
+ // follow-redirects absolutely must not be used in the browser.
2
+ // Neither should the `http` and `http` modules it replaces, yet here we are.
3
+ var http = require("http");
4
+ var https = require("https");
5
+
6
+ /* istanbul ignore next */ // 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: function () {
13
+ // Honestly looking forward to this bug report
14
+ throw new Error("Best viewed in Internet Explorer");
15
+ },
16
+ isBrowser() {
17
+ /* istanbul ignore next */ // eslint-disable-next-line
18
+ return browser && !!console.warn("Exclude follow-redirects from browser builds.");
19
+ },
20
+ };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "follow-redirects",
3
- "version": "1.15.6",
3
+ "version": "1.15.7",
4
4
  "description": "HTTP and HTTPS modules that follow redirects.",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
+ "browser": "nope.js",
7
8
  "files": [
8
9
  "*.js"
9
10
  ],