From 2cb3d92f79fcdda5f99873764009e1b253549058 Mon Sep 17 00:00:00 2001 From: yonmey Date: Thu, 22 Mar 2018 01:04:02 +0100 Subject: [PATCH] Fix - Image URL condition moved --- src/node/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/node/index.js b/src/node/index.js index 9755e9a..99e47a0 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -30,18 +30,18 @@ exports.sendPacket = function sendPacket(instance, packet){ function loadImage(image, cb){ - if(isURL(image)) { - fetch(image) + if(typeof image === 'string'){ + if (isURL(image)) { + fetch(image) .then(resp => resp.buffer()) .then(buffer => loadImage(buffer, cb)) .catch(err => console.error(err)); - } - - if(typeof image === 'string'){ - fs.readFile(image, function(err, buffer){ - if (err) throw err; - loadImage(buffer, cb); - }); + } else { + fs.readFile(image, function(err, buffer){ + if (err) throw err; + loadImage(buffer, cb); + }); + } return; } else if (image instanceof Buffer){ var mime = require('file-type')(image).mime