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-esm: Remove dynamic import to utils
Elian Dorana8fd3be13389
diff --git a/src/services/utils.ts b/src/services/utils.tsindex b14ce5c715..c985c566e6 100644--- a/src/services/utils.ts+++ b/src/services/utils.ts@@ -173,7 +173,7 @@ function replaceAll(string: string, replaceWhat: string, replaceWith: string) {return string.replace(new RegExp(quotedReplaceWhat, "g"), replaceWith);}-function formatDownloadTitle(fileName: string, type: string, mime: string) {+function formatDownloadTitle(fileName: string, type: string | null, mime: string) {if (!fileName) {fileName = "untitled";}@@ -182,7 +182,7 @@ function formatDownloadTitle(fileName: string, type: string, mime: string) {if (type === 'text') {return `${fileName}.html`;- } else if (['relationMap', 'canvas', 'search'].includes(type)) {+ } else if (type && ['relationMap', 'canvas', 'search'].includes(type)) {return `${fileName}.json`;} else {if (!mime) {diff --git a/src/share/routes.ts b/src/share/routes.tsindex 4c892e53c6..51a0c2ff54 100644--- a/src/share/routes.ts+++ b/src/share/routes.ts@@ -15,6 +15,7 @@ import log from "../services/log.js";import SNote from "./shaca/entities/snote.js";import SBranch from "./shaca/entities/sbranch.js";import SAttachment from "./shaca/entities/sattachment.js";+import utils from "../services/utils.js";function getSharedSubTreeRoot(note: SNote): { note?: SNote; branch?: SBranch } {if (note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {@@ -317,8 +318,6 @@ function register(router: Router) {addNoIndexHeader(attachment.note, res);- const utils = require('../services/utils');-const filename = utils.formatDownloadTitle(attachment.title, null, attachment.mime);res.setHeader('Content-Disposition', utils.getContentDisposition(filename));