Skip to content

Commit

Permalink
Avoid ever following JavascriptFetch relations. Fixes #188
Browse files Browse the repository at this point in the history
Munter committed Nov 13, 2020
1 parent e72157b commit 672c6b1
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -678,6 +678,8 @@ async function hyperlink(
if (followSourceMaps) {
relation.to.check = true;
}
} else if (relation.type === 'JavaScriptFetch') {
follow = false;
} else {
follow = true;
}
21 changes: 21 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -2983,4 +2983,25 @@ describe('hyperlink', function () {
todo: 0,
});
});

it('should not follow JavaScriptFetch relations', async function () {
const t = new TapRender();
sinon.spy(t, 'push');
await hyperlink(
{
recursive: false,
root: pathModule.resolve(__dirname, '..', 'testdata', 'fetch'),
inputUrls: ['index.html'],
},
t
);

expect(t.close(), 'to satisfy', {
count: 1,
pass: 1,
fail: 0,
skip: 0,
todo: 0,
});
});
});
3 changes: 3 additions & 0 deletions testdata/fetch/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
fetch('./foo.json').then(console.log);
</script>

0 comments on commit 672c6b1

Please sign in to comment.