Skip to content

Commit e834ab0

Browse files
committed
fix: fix handling of redirects
1 parent c5a2dfe commit e834ab0

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/no-dead-link.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,16 @@ function reporter(context, options = {}) {
295295
: await memorizedIsAliveURI(uri, method, maxRetryCount);
296296
const { ok, redirected, redirectTo, message } = result;
297297

298-
if (!ok) {
299-
const lintMessage = `${uri} is dead. (${message})`;
300-
report(node, new RuleError(lintMessage, { index }));
301-
} else if (redirected && !ruleOptions.ignoreRedirects) {
298+
if (redirected && !ruleOptions.ignoreRedirects) {
302299
const lintMessage = `${uri} is redirected to ${redirectTo}. (${message})`;
303300
const fix = fixer.replaceTextRange(
304301
[index, index + uri.length],
305302
redirectTo,
306303
);
307-
308304
report(node, new RuleError(lintMessage, { fix, index }));
305+
} else if (!ok) {
306+
const lintMessage = `${uri} is dead. (${message})`;
307+
report(node, new RuleError(lintMessage, { index }));
309308
}
310309
};
311310

test/no-dead-link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tester.run('no-dead-link', rule, {
1717
'should success with retrying on error: [npm results for textlint](https://www.npmjs.com/search?q=textlint)',
1818
'should treat 200 OK as alive: https://httpstat.us/200',
1919
'should treat 200 OK. It require User-Agent: Navigate to [MySQL distribution](https://dev.mysql.com/downloads/mysql/) to install MySQL `5.7`.',
20-
'should treat 200 OK. It require User-Agent: https://tools.ietf.org/html/rfc6749',
20+
'should treat 200 OK. It require User-Agent: https://datatracker.ietf.org/doc/html/rfc6749',
2121
{
2222
text:
2323
'should be able to check a URL in a plain text: https://example.com/',

0 commit comments

Comments
 (0)