Skip to content

Commit

Permalink
Adapt to PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Munter committed Sep 22, 2018
1 parent 93ccbcf commit 71a1879
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/assets/Asset.js
Expand Up @@ -388,18 +388,22 @@ class Asset extends EventEmitter {
const { headers = {}, ...requestOptions } =
this.assetGraph.requestOptions || {};
const firstIncomingRelation = this.incomingRelations[0];
let Referer;

if (
firstIncomingRelation &&
firstIncomingRelation.from.protocol &&
firstIncomingRelation.from.protocol.startsWith('http')
) {
headers.Referer = firstIncomingRelation.from.url;
Referer = firstIncomingRelation.from.url;
}

const response = await this.assetGraph.teepee.request({
...requestOptions,
headers,
headers: {
...headers,
Referer
},
method: metadataOnly ? 'HEAD' : 'GET',
url,
json: false
Expand Down
4 changes: 0 additions & 4 deletions test/assets/Asset.js
Expand Up @@ -49,8 +49,6 @@ describe('assets/Asset', function() {

await assetGraph.loadAssets('/');
await assetGraph.populate();

expect(assetGraph, 'to contain asset', 'Css');
});
it('should not add an HTTP referer header to an http request when following a relation from a non-HTTP asset', async function() {
httpception([
Expand All @@ -77,8 +75,6 @@ describe('assets/Asset', function() {
text: '<link rel="stylesheet" href="https://www.example.com/style.css">'
});
await assetGraph.populate();

expect(assetGraph, 'to contain asset', 'Css');
});

it('should error when there is no file handle and the asset is not in a graph', function() {
Expand Down

0 comments on commit 71a1879

Please sign in to comment.