Sergei-Korneev/obsidian-local-images-plus

cannot handle svg file

Closed this issue · 3 comments

for example:

![O(k)](https://wikimedia.org/api/rest_v1/media/math/render/svg/f5ec39041121b14e8c2b1a986c9b04547b223e3c)

O(k)

I find that fromBuffer cannot detect a svg file. It just returns an undefined.

I tried to change if (fileExt == "xml") to if (!fileExt), the bug disappeared.

I hope this bug can be fixed.

export async function fileExtByContent(content: ArrayBuffer) {

  const fileExt = (await fromBuffer(content))?.ext;

  // if XML, probably it is SVG
  if (fileExt == "xml") {
    const buffer = Buffer.from(content);
    if (isSvg(buffer)) return "svg";
  }

  return fileExt;
}

Thank you. Will check this later.

Try new version.