Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit ea1da1e

Browse files
committed
server: Fix rendering of SVG attachments (closes #226)
1 parent 66108c1 commit ea1da1e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/routes/api/image.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,21 @@ function returnImageInt(image: BNote | BRevision | null, res: Response) {
4141
}
4242

4343
function renderSvgAttachment(image: BNote | BRevision, res: Response, attachmentName: string) {
44-
let svgString = '<svg/>'
44+
let svg: string | Buffer = '<svg/>'
4545
const attachment = image.getAttachmentByTitle(attachmentName);
4646

4747
const content = attachment.getContent();
48-
if (attachment && typeof content === "string") {
49-
svgString = content;
48+
if (attachment) {
49+
svg = content;
5050
} else {
5151
// backwards compatibility, before attachments, the SVG was stored in the main note content as a separate key
5252
const contentSvg = image.getJsonContentSafely()?.svg;
5353

5454
if (contentSvg) {
55-
svgString = contentSvg;
55+
svg = contentSvg;
5656
}
5757
}
5858

59-
const svg = svgString
6059
res.set('Content-Type', "image/svg+xml");
6160
res.set("Cache-Control", "no-cache, no-store, must-revalidate");
6261
res.send(svg);

0 commit comments

Comments
 (0)