Browse Source

Fix - Image URL condition moved

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

18
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'){
fetch(image) if (isURL(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 {
fs.readFile(image, function(err, buffer){
if(typeof image === 'string'){ if (err) throw err;
fs.readFile(image, function(err, buffer){ loadImage(buffer, cb);
if (err) throw err; });
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