Skip to content

Commit

Permalink
Update crawler.js
Browse files Browse the repository at this point in the history
  • Loading branch information
baysao committed Oct 13, 2019
1 parent e96ca20 commit 5f7f198
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,11 @@ Crawler.prototype._onContent = function _onContent (error, options, response) {

var injectableTypes = ['html','xhtml','text/xml', 'application/xml', '+xml'];
if (!options.html && !typeis(contentType(response), injectableTypes)){
log('warn','response body is not HTML, skip injecting. Set jQuery to false to suppress this message');
return options.callback(null,response,options.release);
// in case gzip, content-type is undefined, we can test first 100 bytes for tag html
if(!/\<html/.test(response.body.substring(0,100))){
log('warn','response body is not HTML, skip injecting. Set jQuery to false to suppress this message');
return options.callback(null,response,options.release);
}
}

log('debug','Injecting');
Expand Down

0 comments on commit 5f7f198

Please sign in to comment.