Skip to content

Commit 7abac61

Browse files
committed
Avoid ever following JavascriptFetch relations. Fixes #188
1 parent e72157b commit 7abac61

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

lib/index.js

+2
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

+26
Original file line numberDiff line numberDiff line change
@@ -2983,4 +2983,30 @@ 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(
2994+
__dirname,
2995+
'..',
2996+
'testdata',
2997+
'fetch'
2998+
),
2999+
inputUrls: ['index.html'],
3000+
},
3001+
t
3002+
);
3003+
3004+
expect(t.close(), 'to satisfy', {
3005+
count: 1,
3006+
pass: 1,
3007+
fail: 0,
3008+
skip: 0,
3009+
todo: 0,
3010+
});
3011+
});
29863012
});

testdata/fetch/index.html

+3
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)