Skip to content

Commit

Permalink
fix: do not follow irc links (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Nov 2, 2019
1 parent a97b639 commit e55edb1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class LinkChecker extends EventEmitter {
*/
async check(options: CheckOptions) {
options.linksToSkip = options.linksToSkip || [];
options.linksToSkip.push('^mailto:');
options.linksToSkip.push('^mailto:', '^irc:');
let server: http.Server | undefined;
if (!options.path.startsWith('http')) {
const port = options.port || 5000 + Math.round(Math.random() * 1000);
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/protocols/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<a href="irc://irc.freenode.net/%23bootstrap">visit us on irc</a>
</body>
</html>
9 changes: 9 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ describe('linkinator', () => {
assert.strictEqual(results.links.length, 2);
});

it('should not folow non-http[s] links', async () => {
const results = await check({ path: 'test/fixtures/protocols' });
assert.ok(results.passed);
assert.strictEqual(
results.links.filter(x => x.state === LinkState.SKIPPED).length,
1
);
});

it('should not recurse by default', async () => {
const results = await check({ path: 'test/fixtures/recurse' });
assert.strictEqual(results.links.length, 2);
Expand Down

0 comments on commit e55edb1

Please sign in to comment.