From a5a66a12e2ce7d6efe8d1908e3631849c29ccba7 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Mon, 10 Mar 2025 19:30:32 +0100 Subject: [PATCH] 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... --- src/share/routes.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/share/routes.ts b/src/share/routes.ts index 932adfaac..a2dbb6e0d 100644 --- a/src/share/routes.ts +++ b/src/share/routes.ts @@ -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;