Skip to content

Commit

Permalink
A little more defensive for #226
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Oct 1, 2024
1 parent 803d902 commit a805223
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion img.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class Image {
// If the file starts with whitespace or the '<' character, it might be SVG.
// Otherwise, skip the expensive buffer.toString() call
// (no point in unicode encoding a binary file)
let fileContentsPrefix = fileContents.slice(0, 1).toString().trim();
let fileContentsPrefix = fileContents?.slice(0, 1)?.toString()?.trim();
if (!fileContentsPrefix || fileContentsPrefix[0] == "<") {
// remove all newlines for hashing for better cross-OS hash compatibility (Issue #122)
let fileContentsStr = fileContents.toString();
Expand Down

0 comments on commit a805223

Please sign in to comment.