Skip to content

Commit

Permalink
Fix header value check
Browse files Browse the repository at this point in the history
  • Loading branch information
juffalow committed Nov 10, 2021
1 parent cee164d commit e0fb391
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/html/CSS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class CSS extends Test {
}

protected isCached(result: any): boolean {
return Object.prototype.hasOwnProperty.call(result.response.headers, 'cache-control');
return result.response.headers.has('cache-control');
}

protected hasXContentTypeOptionsHeader(result: any): boolean {
return Object.prototype.hasOwnProperty.call(result.response.headers, 'x-content-type-options');
return result.response.headers.has('x-content-type-options');
}

protected isMinified(result: any): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/html/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ class Image extends Test {
}

protected isCached(result: any): boolean {
return Object.prototype.hasOwnProperty.call(result.response.headers, 'cache-control');
return result.response.headers.has('cache-control');
}

protected hasXContentTypeOptionsHeader(result: any): boolean {
return Object.prototype.hasOwnProperty.call(result.response.headers, 'x-content-type-options');
return result.response.headers.has('x-content-type-options');
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/html/JavaScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class JavaScript extends Test {

const result = await request.get(script);

console.log(result.response.headers);
console.log(Object.prototype.hasOwnProperty.call(result.response.headers, 'cache-control'));
console.log('cache-control' in result.response.headers)
console.log(result.response.headers.has('cache-control'))

const isFileAvailabe = {
status: this.isFileAvailable(result) ? 'SUCCESS' : 'ERROR',
title: 'Available',
Expand Down Expand Up @@ -88,11 +93,11 @@ class JavaScript extends Test {
}

protected isCached(result: any): boolean {
return Object.prototype.hasOwnProperty.call(result.response.headers, 'cache-control');
return result.response.headers.has('cache-control');
}

protected hasXContentTypeOptionsHeader(result: any): boolean {
return Object.prototype.hasOwnProperty.call(result.response.headers, 'x-content-type-options');
return result.response.headers.has('x-content-type-options');
}

protected isMinified(result: any): boolean {
Expand Down

0 comments on commit e0fb391

Please sign in to comment.