chore(share): fix tsc nagging about svg not existing on unknown

JSON and TS without using a validation library like zod, is really a bit of a pain in the backside...
This commit is contained in:
Panagiotis Papadopoulos 2025-03-10 19:30:32 +01:00
parent 2a5ac80c05
commit a5a66a12e2

View File

@ -115,7 +115,14 @@ function renderImageAttachment(image: SNote, res: Response, attachmentName: stri
svgString = content;
} else {
// backwards compatibility, before attachments, the SVG was stored in the main note content as a separate key
const contentSvg = image.getJsonContentSafely()?.svg;
const possibleSvgContent = image.getJsonContentSafely();
const contentSvg = (typeof possibleSvgContent === "object"
&& possibleSvgContent !== null
&& "svg" in possibleSvgContent
&& typeof possibleSvgContent.svg === "string")
? possibleSvgContent.svg
: null;
if (contentSvg) {
svgString = contentSvg;