From e5b35fe3528cc0edda0eb121d3e1b8197536eae0 Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Tue, 19 Apr 2016 11:08:28 +0100 Subject: [PATCH] fix: don't try to encode SVG if there's no body Fixes #95 --- lib/image.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/image.js b/lib/image.js index db7fcd6..7514689 100644 --- a/lib/image.js +++ b/lib/image.js @@ -18,7 +18,8 @@ function image(url) { debug('image loaded: %s', url); // if the url is SVG, let's compress and use the XML directly - if (mime.lookup(url) === 'image/svg+xml' && !inliner.options.nosvg) { + if (res.body && mime.lookup(url) === 'image/svg+xml' && + !inliner.options.nosvg) { return new Promise(function (resolve, reject) { svgo.optimize(res.body.toString(), function (result) { debug('optimising svg');