From f650cca6523d8cb5c75437c6762f672ae2eab360 Mon Sep 17 00:00:00 2001
From: Jin <22962980+JYC333@users.noreply.github.com>
Date: Wed, 4 Jun 2025 09:47:05 +0200
Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20replace=20substr=20w?=
=?UTF-8?q?ith=20substring?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
apps/server/src/services/notes.ts | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/apps/server/src/services/notes.ts b/apps/server/src/services/notes.ts
index f06e07ed8..4c82c0e8c 100644
--- a/apps/server/src/services/notes.ts
+++ b/apps/server/src/services/notes.ts
@@ -76,7 +76,7 @@ function deriveMime(type: string, mime?: string) {
function copyChildAttributes(parentNote: BNote, childNote: BNote) {
for (const attr of parentNote.getAttributes()) {
if (attr.name.startsWith("child:")) {
- const name = attr.name.substr(6);
+ const name = attr.name.substring(6);
const hasAlreadyTemplate = childNote.hasRelation("template");
if (hasAlreadyTemplate && attr.type === "relation" && name === "template") {
@@ -472,7 +472,7 @@ async function downloadImage(noteId: string, imageUrl: string) {
if (imageUrl.toLowerCase().startsWith("file://")) {
imageBuffer = await new Promise((res, rej) => {
- const localFilePath = imageUrl.substr("file://".length);
+ const localFilePath = imageUrl.substring("file://".length);
return fs.readFile(localFilePath, (err, data) => {
if (err) {
@@ -521,14 +521,14 @@ function downloadImages(noteId: string, content: string) {
const inlineImageMatch = /^data:image\/[a-z]+;base64,/.exec(url);
if (inlineImageMatch) {
- const imageBase64 = url.substr(inlineImageMatch[0].length);
+ const imageBase64 = url.substring(inlineImageMatch[0].length);
const imageBuffer = Buffer.from(imageBase64, "base64");
const attachment = imageService.saveImageToAttachment(noteId, imageBuffer, "inline image", true, true);
const encodedTitle = encodeURIComponent(attachment.title);
- content = `${content.substr(0, imageMatch.index)}
${title}${content.substr(attachmentMatch.index + attachmentMatch[0].length)}`;
+ content = `${content.substring(0, attachmentMatch.index)}${title}${content.substring(attachmentMatch.index + attachmentMatch[0].length)}`;
}
// removing absolute references to server to keep it working between instances,