Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
server: Fix SVG backwards compatibility (fixes #238)
Elian Doran8b799755003a
diff --git a/src/becca/entities/bnote.ts b/src/becca/entities/bnote.tsindex edb7f67e3c..a1d4cf395b 100644--- a/src/becca/entities/bnote.ts+++ b/src/becca/entities/bnote.ts@@ -1151,7 +1151,7 @@ class BNote extends AbstractBeccaEntity<BNote> {.map(row => new BAttachment(row));}- getAttachmentByTitle(title: string): BAttachment {+ getAttachmentByTitle(title: string): BAttachment | undefined {// cannot use SQL to filter by title since it can be encryptedreturn this.getAttachments().filter(attachment => attachment.title === title)[0];}diff --git a/src/routes/api/image.ts b/src/routes/api/image.tsindex 0c6f29124c..926ad3ead1 100644--- a/src/routes/api/image.ts+++ b/src/routes/api/image.ts@@ -44,9 +44,8 @@ function renderSvgAttachment(image: BNote | BRevision, res: Response, attachmentlet svg: string | Buffer = '<svg/>'const attachment = image.getAttachmentByTitle(attachmentName);- const content = attachment.getContent();if (attachment) {- svg = content;+ svg = attachment.getContent();} else {// backwards compatibility, before attachments, the SVG was stored in the main note content as a separate keyconst contentSvg = image.getJsonContentSafely()?.svg;