Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: follow-redirects/follow-redirects
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.15.5
Choose a base ref
...
head repository: follow-redirects/follow-redirects
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.15.9
Choose a head ref
  • 14 commits
  • 8 files changed
  • 1 contributor

Commits on Mar 14, 2024

  1. Use GitHub for disclosure.

    RubenVerborgh authored Mar 14, 2024
    2
    Copy the full SHA
    8526b4a View commit details
  2. Drop Proxy-Authorization across hosts.

    RubenVerborgh committed Mar 14, 2024
    Copy the full SHA
    c4f847f View commit details
  3. Release version 1.15.6 of the npm package.

    RubenVerborgh committed Mar 14, 2024
    1
    Copy the full SHA
    35a517c View commit details

Commits on Sep 3, 2024

  1. Graceful browser degradation.

    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    97d1f9a View commit details
  2. Release version 1.15.7 of the npm package.

    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    760757f View commit details
  3. Fix typo.

    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    fda0faf View commit details
  4. Test on Node 20 and 22.

    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    f3711d7 View commit details
  5. Copy the full SHA
    ca49e44 View commit details
  6. Fix native URL test for Node 20.

    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    458ca8e View commit details
  7. Return subtlety.

    Fixes #266
    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    a8d1cee View commit details
  8. Release version 1.15.8 of the npm package.

    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    62558f0 View commit details
  9. Fix url field.

    RubenVerborgh committed Sep 3, 2024
    Copy the full SHA
    d2aaa97 View commit details

Commits on Sep 6, 2024

  1. Attempt much more gentle detection.

    Closes #268
    RubenVerborgh committed Sep 6, 2024
    Copy the full SHA
    31a1abf View commit details
  2. Release version 1.15.9 of the npm package.

    RubenVerborgh committed Sep 6, 2024
    Copy the full SHA
    e4e55c7 View commit details
Showing with 41 additions and 18 deletions.
  1. +1 −0 .eslintrc
  2. +5 −1 .github/workflows/ci.yml
  3. +1 −4 SECURITY.md
  4. +22 −8 index.js
  5. +2 −2 package-lock.json
  6. +2 −2 package.json
  7. +4 −0 test/server.js
  8. +4 −1 test/test.js
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
no-alert: "error",
no-caller: "error",
no-case-declarations: "error",
no-console: ["error", { allow: ["warn"] }],
no-div-regex: "error",
no-else-return: "error",
no-empty-function: "error",
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/setup-node@v3
with:
node-version: '18.0'
node-version: '22.0'
- uses: actions/checkout@v4
- run: npm ci
- run: npm run lint
@@ -51,6 +51,10 @@ jobs:
- '17.x'
- '18.0'
- '18.x'
- '20.0'
- '20.x'
- '22.0'
- '22.x'
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
5 changes: 1 addition & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Reporting a Vulnerability

If you discover a security vulnerability in follow-redirects please disclose it via [our huntr page](https://huntr.dev/repos/follow-redirects/follow-redirects). Bounties, CVE assignment, response times and past reports are all there.


Thank you for improving the security of follow-redirects.
If you discover a security vulnerability in follow-redirects please disclose it via https://github.com/follow-redirects/follow-redirects/security/advisories
30 changes: 22 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -6,10 +6,21 @@ var Writable = require("stream").Writable;
var assert = require("assert");
var debug = require("./debug");

// Preventive platform detection
// istanbul ignore next
(function detectUnsupportedEnvironment() {
var looksLikeNode = typeof process !== "undefined";
var looksLikeBrowser = typeof window !== "undefined" && typeof document !== "undefined";
var looksLikeV8 = isFunction(Error.captureStackTrace);
if (!looksLikeNode && (looksLikeBrowser || !looksLikeV8)) {
console.warn("The follow-redirects package should be excluded from browser builds.");
}
}());

// Whether to use the native URL object or the legacy url module
var useNativeURL = false;
try {
assert(new URL());
assert(new URL(""));
}
catch (error) {
useNativeURL = error.code === "ERR_INVALID_URL";
@@ -346,17 +357,17 @@ RedirectableRequest.prototype._performRequest = function () {
var buffers = this._requestBodyBuffers;
(function writeNext(error) {
// Only write if this request has not been redirected yet
/* istanbul ignore else */
// istanbul ignore else
if (request === self._currentRequest) {
// Report any write errors
/* istanbul ignore if */
// istanbul ignore if
if (error) {
self.emit("error", error);
}
// Write the next buffer if there are still left
else if (i < buffers.length) {
var buffer = buffers[i++];
/* istanbul ignore else */
// istanbul ignore else
if (!request.finished) {
request.write(buffer.data, buffer.encoding, writeNext);
}
@@ -461,7 +472,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
redirectUrl.protocol !== "https:" ||
redirectUrl.host !== currentHost &&
!isSubdomain(redirectUrl.host, currentHost)) {
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
}

// Evaluate the beforeRedirect callback
@@ -552,7 +563,7 @@ function noop() { /* empty */ }

function parseUrl(input) {
var parsed;
/* istanbul ignore else */
// istanbul ignore else
if (useNativeURL) {
parsed = new URL(input);
}
@@ -567,7 +578,7 @@ function parseUrl(input) {
}

function resolveUrl(relative, base) {
/* istanbul ignore next */
// istanbul ignore next
return useNativeURL ? new URL(relative, base) : parseUrl(url.resolve(base, relative));
}

@@ -616,7 +627,10 @@ function removeMatchingHeaders(regex, headers) {
function createErrorType(code, message, baseClass) {
// Create constructor
function CustomError(properties) {
Error.captureStackTrace(this, this.constructor);
// istanbul ignore else
if (isFunction(Error.captureStackTrace)) {
Error.captureStackTrace(this, this.constructor);
}
Object.assign(this, properties || {});
this.code = code;
this.message = this.cause ? message + ": " + this.cause.message : message;
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "follow-redirects",
"version": "1.15.5",
"version": "1.15.9",
"description": "HTTP and HTTPS modules that follow redirects.",
"license": "MIT",
"main": "index.js",
@@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "git@github.com:follow-redirects/follow-redirects.git"
"url": "git+ssh://git@github.com/follow-redirects/follow-redirects.git"
},
"homepage": "https://github.com/follow-redirects/follow-redirects",
"bugs": {
4 changes: 4 additions & 0 deletions test/server.js
Original file line number Diff line number Diff line change
@@ -60,6 +60,10 @@ module.exports = function (defaultPorts) {

function stopServer(server) {
return new Promise(function (resolve, reject) {
// Node 19 uses KeepAlive by default
if (server.closeIdleConnections) {
server.closeIdleConnections();
}
server.close(function (error) {
return error ? reject(error) : resolve();
});
5 changes: 4 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -607,7 +607,9 @@ describe("follow-redirects", function () {

return server.start(app)
.then(asPromise(function (resolve, reject) {
var req = http.get("http://localhost:3600/data", concatJson(reject, reject));
var opts = url.parse("http://localhost:3600/data");
opts.agent = new http.Agent({ keepAlive: false });
var req = http.get(opts, concatJson(reject, reject));
req.on("error", reject);
req.setTimeout(100, function () {
throw new Error("should not have timed out");
@@ -1529,6 +1531,7 @@ describe("follow-redirects", function () {

[
"Authorization",
"Proxy-Authorization",
"Cookie",
].forEach(function (header) {
describe("when the client passes an header named " + header, function () {