Browse Source

Fix - Image URL condition moved

pull/196/head
yonmey 7 years ago
parent
commit
2cb3d92f79
  1. 8
      src/node/index.js

8
src/node/index.js

@ -30,18 +30,18 @@ exports.sendPacket = function sendPacket(instance, packet){
function loadImage(image, cb){ function loadImage(image, cb){
if(isURL(image)) { if(typeof image === 'string'){
if (isURL(image)) {
fetch(image) fetch(image)
.then(resp => resp.buffer()) .then(resp => resp.buffer())
.then(buffer => loadImage(buffer, cb)) .then(buffer => loadImage(buffer, cb))
.catch(err => console.error(err)); .catch(err => console.error(err));
} } else {
if(typeof image === 'string'){
fs.readFile(image, function(err, buffer){ fs.readFile(image, function(err, buffer){
if (err) throw err; if (err) throw err;
loadImage(buffer, cb); loadImage(buffer, cb);
}); });
}
return; return;
} else if (image instanceof Buffer){ } else if (image instanceof Buffer){
var mime = require('file-type')(image).mime var mime = require('file-type')(image).mime

Loading…
Cancel
Save