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
convert absolute image attachment URLs to relative without domain, fixes #4509
zadam439743d2b099
diff --git a/src/services/notes.js b/src/services/notes.jsindex c325bba9bb..6e6bbfd76f 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -636,6 +636,10 @@ function saveAttachments(note, content) {content = `${content.substr(0, attachmentMatch.index)}<a class="reference-link" href="#root/${note.noteId}?viewMode=attachments&attachmentId=${attachment.attachmentId}">${title}</a>${content.substr(attachmentMatch.index + attachmentMatch[0].length)}`;}+ // removing absolute references to server to keep it working between instances,+ // we also omit / at the beginning to keep the paths relative+ content = content.replace(/src="[^"]*\/api\/attachments\//g, 'src="api/attachments/');+return content;}