jrit / web-resource-inliner

Inlines img, script and link tags into the same file
MIT License
66 stars 29 forks source link

Error cannot trigger when local file is not found #43

Open scandox opened 5 years ago

scandox commented 5 years ago

In util.getFileReplacement where the file is local, the callback cannot be reached if the file can't be found:

var result = ( new datauri( util.getInlineFilePath( src, settings.relativeTo ) ) ).content;
callback( result === undefined ? new Error( "Local file not found" ) : null, result );

The second line won't be reached if datauri throws an error. As I understand it calling datauri constructor with just a file path means it will use encodeSync and that throws. So this would have to be surrounded with a try...catch?

Let me know if I'm missing a trick here.