Skip to content

Commit

Permalink
Fix bug where local srcset images would be categorized as external
Browse files Browse the repository at this point in the history
  • Loading branch information
Munter committed Nov 16, 2019
1 parent 5aae7ea commit 4613190
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ async function hyperlink(
} else {
reportTest({
...redirectReport,
expected: `${log[0].statusCode} ${url} --> 200 ${log[log.length - 1].redirectUri}`,
expected: `${log[0].statusCode} ${url} --> 200 ${
log[log.length - 1].redirectUri
}`,
actual,
ok: false
});
Expand Down Expand Up @@ -636,7 +638,7 @@ async function hyperlink(
if (assetTypesWithoutRelations.includes(relation.to.type)) {
// If we are handling local file-urls, follow but mark as end-of-line in processing
if (
relation.from.protocol === 'file:' &&
relation.from.nonInlineAncestor.protocol === 'file:' &&
relation.to.protocol === 'file:'
) {
relation.to.stopProcessing = !recursive;
Expand Down
26 changes: 26 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2836,4 +2836,30 @@ describe('hyperlink', function() {
expect(t.close(), 'to satisfy', { pass: 3, fail: 2 });
});
});

it('should resolve local srcset images as internal', async function() {
const t = new TapRender();
sinon.spy(t, 'push');
await hyperlink(
{
recursive: false,
root: pathModule.resolve(
__dirname,
'..',
'testdata',
'pictureSourceSrcsetWebp'
),
inputUrls: ['index.html']
},
t
);

expect(t.close(), 'to satisfy', {
count: 3,
pass: 3,
fail: 0,
skip: 0,
todo: 0
});
});
});
Binary file added testdata/pictureSourceSrcsetWebp/heydonworks.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
20 changes: 20 additions & 0 deletions testdata/pictureSourceSrcsetWebp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>

<body>

<picture>
<source srcset="heydonworks.webp" type="image/webp">
<img src="heydonworks.jpg" alt="heydonworks’s twitter avatar" loading="lazy" class="avatar">
</picture>

</body>

</html>

0 comments on commit 4613190

Please sign in to comment.