Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,17 +732,6 @@ async function hyperlink(
);
}

// Check Content-Type vs. incoming relation targetTypes:

for (const asset of ag.findAssets({ expectedTypes: { $exists: true } })) {
const incompatibleTypes = [...asset.expectedTypes].filter(
expectedType => !asset._isCompatibleWith(expectedType)
);
if (incompatibleTypes.length > 0) {
asset._warnIncompatibleTypes([...incompatibleTypes, asset.type]);
}
}

// Check preconnects:

const preconnectAssetsToCheck = ag.findAssets({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"homepage": "https://github.com/Munter/hyperlink",
"dependencies": {
"assetgraph": "4.8.0",
"assetgraph": "^5.8.3",
"async": "^2.6.0",
"optimist": "^0.6.1",
"pretty-bytes": "^4.0.2",
Expand Down
107 changes: 0 additions & 107 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,113 +139,6 @@ describe('hyperlink', function() {
});
});

it('should complain if an asset loaded has an unexpected Content-Type', async function() {
httpception([
{
request: 'GET https://example.com/',
response: {
statusCode: 200,
headers: {
'Content-Type': 'text/html; charset=UTF-8'
},
body: `
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
</body>
</html>
`
}
},
{
request: 'GET https://example.com/styles.css',
response: {
headers: {
'Content-Type': 'image/png'
},
body: 'div { color: maroon; }'
}
}
]);

const t = new TapRender();
sinon.spy(t, 'push');
await hyperlink(
{
root: 'https://example.com/',
inputUrls: ['https://example.com/']
},
t
);

expect(t.close(), 'to satisfy', { fail: 1 });
expect(t.push, 'to have a call satisfying', () => {
t.push(null, {
ok: false,
operator: 'content-type-mismatch',
name: 'content-type-mismatch https://example.com/styles.css',
actual: 'Asset is used as both Css and Png',
at:
'https://example.com/ (5:44) <link rel="stylesheet" href="styles.css">'
});
});
});

it('should complain if an asset being HEADed has an unexpected Content-Type', async function() {
httpception([
{
request: 'GET https://example.com/',
response: {
statusCode: 200,
headers: {
'Content-Type': 'text/html; charset=UTF-8'
},
body: `
<!DOCTYPE html>
<html>
<head></head>
<body>
<img src="hey.png">
</body>
</html>
`
}
},
{
request: 'HEAD https://example.com/hey.png',
response: {
headers: {
'Content-Type': 'text/plain'
}
}
}
]);

const t = new TapRender();
sinon.spy(t, 'push');
await hyperlink(
{
root: 'https://example.com/',
inputUrls: ['https://example.com/']
},
t
);

expect(t.close(), 'to satisfy', { fail: 1 });
expect(t.push, 'to have a call satisfying', () => {
t.push(null, {
ok: false,
operator: 'content-type-mismatch',
name: 'content-type-mismatch https://example.com/hey.png',
actual: 'Asset is used as both Image and Text',
at: 'https://example.com/ (6:25) <img src="hey.png">'
});
});
});

it('should complain if an asset being HEADed has no Content-Type', async function() {
httpception([
{
Expand Down