From fba9afd6f55ddaabc43ec33074501ab2f837856c Mon Sep 17 00:00:00 2001 From: anasasilva Date: Thu, 20 Dec 2018 17:16:24 +0000 Subject: [PATCH] Shorter code --- browser/main/lib/dataApi/attachmentManagement.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/browser/main/lib/dataApi/attachmentManagement.js b/browser/main/lib/dataApi/attachmentManagement.js index b46c070d..5c310ecf 100644 --- a/browser/main/lib/dataApi/attachmentManagement.js +++ b/browser/main/lib/dataApi/attachmentManagement.js @@ -465,14 +465,10 @@ function importAttachments (markDownContent, filepath, storageKey, noteKey) { const groupIndex = 2 while (attachPath) { - attachmentPaths.push(attachPath[groupIndex]) - - if (path.isAbsolute(attachPath[groupIndex])) { - promiseArray.push(this.copyAttachment(attachPath[groupIndex], storageKey, noteKey)) - } else { - const fullPath = path.join(path.dirname(filepath), attachPath[groupIndex]) - promiseArray.push(this.copyAttachment(fullPath, storageKey, noteKey)) - } + let attachmentPath = attachPath[groupIndex] + attachmentPaths.push(attachmentPath) + attachmentPath = path.isAbsolute(attachmentPath) ? attachmentPath : path.join(path.dirname(filepath), attachmentPath) + promiseArray.push(this.copyAttachment(attachmentPath, storageKey, noteKey)) attachPath = nameRegex.exec(markDownContent) }