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

Commit a8fd3be

Browse files
committed
server-esm: Remove dynamic import to utils
1 parent 0c87fab commit a8fd3be

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/services/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function replaceAll(string: string, replaceWhat: string, replaceWith: string) {
173173
return string.replace(new RegExp(quotedReplaceWhat, "g"), replaceWith);
174174
}
175175

176-
function formatDownloadTitle(fileName: string, type: string, mime: string) {
176+
function formatDownloadTitle(fileName: string, type: string | null, mime: string) {
177177
if (!fileName) {
178178
fileName = "untitled";
179179
}
@@ -182,7 +182,7 @@ function formatDownloadTitle(fileName: string, type: string, mime: string) {
182182

183183
if (type === 'text') {
184184
return `${fileName}.html`;
185-
} else if (['relationMap', 'canvas', 'search'].includes(type)) {
185+
} else if (type && ['relationMap', 'canvas', 'search'].includes(type)) {
186186
return `${fileName}.json`;
187187
} else {
188188
if (!mime) {

src/share/routes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import log from "../services/log.js";
1515
import SNote from "./shaca/entities/snote.js";
1616
import SBranch from "./shaca/entities/sbranch.js";
1717
import SAttachment from "./shaca/entities/sattachment.js";
18+
import utils from "../services/utils.js";
1819

1920
function getSharedSubTreeRoot(note: SNote): { note?: SNote; branch?: SBranch } {
2021
if (note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {
@@ -317,8 +318,6 @@ function register(router: Router) {
317318

318319
addNoIndexHeader(attachment.note, res);
319320

320-
const utils = require('../services/utils');
321-
322321
const filename = utils.formatDownloadTitle(attachment.title, null, attachment.mime);
323322

324323
res.setHeader('Content-Disposition', utils.getContentDisposition(filename));

0 commit comments

Comments
 (0)