Browse Source

Merge pull request #196 from yonmey/image-url-parsing-fix

Fix - Image URL condition moved
pull/246/head
jeromewu 6 years ago committed by GitHub
parent
commit
343246f2ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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