mirror of
https://github.com/remy/inliner.git
synced 2024-10-26 18:49:55 +03:00
fix: don't bail on corrupted URLs
Fixes #104 It will warn about them, but not fail the job, instead replacing the URL with '' (which is just as bad as the corrupted url, but at least it finishes).
This commit is contained in:
parent
0ae1301641
commit
0772d51069
12
lib/get.js
12
lib/get.js
@ -68,13 +68,17 @@ module.exports = function get(url, options) {
|
||||
request(encodeURI(url), settings, function response(error, res, body) {
|
||||
if (error) {
|
||||
debug('request failed: %s', error.message);
|
||||
return reject(error);
|
||||
inliner.emit('warning', 'failed to request ' + base + ' (' + error.message + ')');
|
||||
// return reject(error);
|
||||
body = '';
|
||||
res = {
|
||||
headers: {},
|
||||
};
|
||||
} else if (res.statusCode !== 200) {
|
||||
inliner.emit('warning', res.statusCode + ' on ' + base);
|
||||
}
|
||||
|
||||
debug('response: %s %s', res.statusCode, url);
|
||||
if (res.statusCode !== 200) {
|
||||
inliner.emit('warning', res.statusCode + ' on ' + base);
|
||||
}
|
||||
|
||||
if (res.statusCode >= 400) {
|
||||
body = '';
|
||||
|
1
test/fixtures/bad-url.result.html
vendored
Normal file
1
test/fixtures/bad-url.result.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<img src="data:undefined;base64,">
|
1
test/fixtures/bad-url.src.html
vendored
Normal file
1
test/fixtures/bad-url.src.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<img src="http:////l.yimg.com//ts//api//res//1.2//a7RcmRbkGrGLwQ2v.eoRUQ--//YXBwaWQ9eWhvbWVydW47cT00MDtzbT0xO3c9NjAwO2g9MTI1NA--//https:////s.yimg.com//av//moneyball//ads//1465557018638-5668.jpg">
|
Loading…
Reference in New Issue
Block a user