Permalink
Browse files

handle errors from Will Peavy's HTML Minifier

  • Loading branch information...
1 parent be0eb54 commit 0c7732e644c632f8ebce57529ff24b2ce7932620 @alexlamsl alexlamsl committed Nov 24, 2016
Showing with 17 additions and 7 deletions.
  1. +17 −7 benchmark.js
View
@@ -309,14 +309,24 @@ run(fileNames.map(function(fileName) {
res.on('data', function(chunk) {
response += chunk;
}).on('end', function() {
- // Extract result from <textarea/>
- var start = response.indexOf('>', response.indexOf('<textarea'));
- var end = response.lastIndexOf('</textarea>');
- var result = response.slice(start + 1, end).replace(/<\\\//g, '</');
var info = infos.willpeavy;
- writeText(info.filePath, result, function() {
- readSizes(info, done);
- });
+ if (res.statusCode === 200) {
+ // Extract result from <textarea/>
+ var start = response.indexOf('>', response.indexOf('<textarea'));
+ var end = response.lastIndexOf('</textarea>');
+ var result = response.slice(start + 1, end).replace(/<\\\//g, '</');
+ writeText(info.filePath, result, function() {
+ readSizes(info, done);
+ });
+ }
+ // Site refused to process content
+ else {
+ info.size = 0;
+ info.gzSize = 0;
+ info.lzSize = 0;
+ info.brSize = 0;
+ done();
+ }
});
}).end(querystring.stringify({
html: data

0 comments on commit 0c7732e

Please sign in to comment.