follow-redirects 1.15.7 → 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 +20 -14
- package/package.json +2 -3
- package/nope.js +0 -20
package/index.js
CHANGED
@@ -5,19 +5,22 @@ 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
8
|
|
10
|
-
//
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
+
}());
|
16
19
|
|
17
20
|
// Whether to use the native URL object or the legacy url module
|
18
21
|
var useNativeURL = false;
|
19
22
|
try {
|
20
|
-
assert(new URL());
|
23
|
+
assert(new URL(""));
|
21
24
|
}
|
22
25
|
catch (error) {
|
23
26
|
useNativeURL = error.code === "ERR_INVALID_URL";
|
@@ -354,17 +357,17 @@ RedirectableRequest.prototype._performRequest = function () {
|
|
354
357
|
var buffers = this._requestBodyBuffers;
|
355
358
|
(function writeNext(error) {
|
356
359
|
// Only write if this request has not been redirected yet
|
357
|
-
|
360
|
+
// istanbul ignore else
|
358
361
|
if (request === self._currentRequest) {
|
359
362
|
// Report any write errors
|
360
|
-
|
363
|
+
// istanbul ignore if
|
361
364
|
if (error) {
|
362
365
|
self.emit("error", error);
|
363
366
|
}
|
364
367
|
// Write the next buffer if there are still left
|
365
368
|
else if (i < buffers.length) {
|
366
369
|
var buffer = buffers[i++];
|
367
|
-
|
370
|
+
// istanbul ignore else
|
368
371
|
if (!request.finished) {
|
369
372
|
request.write(buffer.data, buffer.encoding, writeNext);
|
370
373
|
}
|
@@ -560,7 +563,7 @@ function noop() { /* empty */ }
|
|
560
563
|
|
561
564
|
function parseUrl(input) {
|
562
565
|
var parsed;
|
563
|
-
|
566
|
+
// istanbul ignore else
|
564
567
|
if (useNativeURL) {
|
565
568
|
parsed = new URL(input);
|
566
569
|
}
|
@@ -575,7 +578,7 @@ function parseUrl(input) {
|
|
575
578
|
}
|
576
579
|
|
577
580
|
function resolveUrl(relative, base) {
|
578
|
-
|
581
|
+
// istanbul ignore next
|
579
582
|
return useNativeURL ? new URL(relative, base) : parseUrl(url.resolve(base, relative));
|
580
583
|
}
|
581
584
|
|
@@ -624,7 +627,10 @@ function removeMatchingHeaders(regex, headers) {
|
|
624
627
|
function createErrorType(code, message, baseClass) {
|
625
628
|
// Create constructor
|
626
629
|
function CustomError(properties) {
|
627
|
-
|
630
|
+
// istanbul ignore else
|
631
|
+
if (isFunction(Error.captureStackTrace)) {
|
632
|
+
Error.captureStackTrace(this, this.constructor);
|
633
|
+
}
|
628
634
|
Object.assign(this, properties || {});
|
629
635
|
this.code = code;
|
630
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,20 +0,0 @@
|
|
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
|
-
};
|