Skip to content

Commit 4c2c6c5

Browse files
authored
Merge pull request #189 from Munter/disable-following-fetch
Avoid ever following JavascriptFetch relations. Fixes #188
2 parents 06da3d4 + 672c6b1 commit 4c2c6c5

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ async function hyperlink(
678678
if (followSourceMaps) {
679679
relation.to.check = true;
680680
}
681+
} else if (relation.type === 'JavaScriptFetch') {
682+
follow = false;
681683
} else {
682684
follow = true;
683685
}

test/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,4 +2983,25 @@ describe('hyperlink', function () {
29832983
todo: 0,
29842984
});
29852985
});
2986+
2987+
it('should not follow JavaScriptFetch relations', async function () {
2988+
const t = new TapRender();
2989+
sinon.spy(t, 'push');
2990+
await hyperlink(
2991+
{
2992+
recursive: false,
2993+
root: pathModule.resolve(__dirname, '..', 'testdata', 'fetch'),
2994+
inputUrls: ['index.html'],
2995+
},
2996+
t
2997+
);
2998+
2999+
expect(t.close(), 'to satisfy', {
3000+
count: 1,
3001+
pass: 1,
3002+
fail: 0,
3003+
skip: 0,
3004+
todo: 0,
3005+
});
3006+
});
29863007
});

testdata/fetch/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
fetch('./foo.json').then(console.log);
3+
</script>

0 commit comments

Comments
 (0)