Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c68f445

Browse files
committedMar 10, 2025·
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 d1e07a0 commit c68f445

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)
Please sign in to comment.