Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/proto/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = {
//max retry count will default to 2 seconds if not provided in options
let retryCount = opts.retryCount || 2;

// allow disabling redirects with '0'. default to 8 if not provided in options
let maxRedirects = (typeof opts.maxRedirects === 'number') ? opts.maxRedirects : 8;

//fallback retry delay will default to 60 seconds not provided in options
let fallbackRetryDelayInMs = ms(opts.fallbackRetryDelay || '60s');

Expand All @@ -42,7 +45,7 @@ module.exports = {
agent: new ProxyAgent(),
use_proxy_from_env_var: false,
user_agent: user_agent,
follow_max: 8,
follow_max: maxRedirects,
follow_keep_method: true,
response_timeout: ms(timeout),
open_timeout: ms(open_timeout),
Expand Down
11 changes: 11 additions & 0 deletions test/link-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ describe('link-check', function () {
});
});

it('should allow disabling redirects', function (done) {
linkCheck(baseUrl + '/foo/redirect', {maxRedirects: 0}, function (err, result) {
expect(err).to.be(null);
expect(result.link).to.be(baseUrl + '/foo/redirect');
expect(result.status).to.be('dead');
expect(result.statusCode).to.be(302);
expect(result.err).to.be(null);
done();
});
});

it('should handle valid mailto', function (done) {
linkCheck('mailto:[email protected]', function (err, result) {
expect(err).to.be(null);
Expand Down