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){ @@ -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

Loading…
Cancel
Save