Skip to content

Commit 4b34867

Browse files
committed
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...
1 parent c209ab8 commit 4b34867

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/share/routes.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ function renderImageAttachment(image: SNote, res: Response, attachmentName: stri
115115
svgString = content;
116116
} else {
117117
// backwards compatibility, before attachments, the SVG was stored in the main note content as a separate key
118-
const contentSvg = image.getJsonContentSafely()?.svg;
118+
const possibleSvgContent = image.getJsonContentSafely();
119+
120+
const contentSvg = (typeof possibleSvgContent === "object"
121+
&& possibleSvgContent !== null
122+
&& "svg" in possibleSvgContent
123+
&& typeof possibleSvgContent.svg === "string")
124+
? possibleSvgContent.svg
125+
: null;
119126

120127
if (contentSvg) {
121128
svgString = contentSvg;

0 commit comments

Comments
 (0)