diff --git a/src/no-dead-link.js b/src/no-dead-link.js index c036303..5b766b0 100644 --- a/src/no-dead-link.js +++ b/src/no-dead-link.js @@ -20,6 +20,7 @@ const DEFAULT_OPTIONS = { interval: 500, // The length of time in milliseconds before the interval count resets. Must be finite. [Experimental] intervalCap: 8, // The max number of runs in the given interval of time. [Experimental] keepAlive: false, // {boolean} if it is true, use keepAlive for checking request [Experimental] + userAgent: 'textlint-rule-no-dead-link/1.0' // {String} a UserAgent }; // Adopted from http://stackoverflow.com/a/3809435/951517 @@ -120,7 +121,7 @@ const createFetchWithRuleDefaults = (ruleOptions) => { // to avoid ECONNRESET error // https://github.com/textlint-rule/textlint-rule-no-dead-link/issues/111 headers: { - 'User-Agent': 'textlint-rule-no-dead-link/1.0', + 'User-Agent': ruleOptions.userAgent, 'Accept': '*/*', // Same host for target url // https://github.com/textlint-rule/textlint-rule-no-dead-link/issues/111 diff --git a/test/no-dead-link.js b/test/no-dead-link.js index 81770dd..8e96b11 100644 --- a/test/no-dead-link.js +++ b/test/no-dead-link.js @@ -106,6 +106,13 @@ tester.run('no-dead-link', rule, { ignoreRedirects: true, }, }, + // https://github.com/textlint-rule/textlint-rule-no-dead-link/issues/128 + { + text: 'should treat 200 OK. It requires browser-like User-Agent: https://issues.jenkins-ci.org/browse/JENKINS-59261', + options: { + userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36' + } + } ], invalid: [ {