diff --git a/CHANGELOG.md b/CHANGELOG.md index af9754dd..a936dc65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### 🐞 Fixes - [#153](https://github.com/estruyf/vscode-front-matter/issues/153): Support old date formatting for date-fns +- [#156](https://github.com/estruyf/vscode-front-matter/issues/156): Fix for uploading media files into a new folder ## [5.1.1] - 2021-10-14 diff --git a/src/commands/Dashboard.ts b/src/commands/Dashboard.ts index e8748889..c6ac8102 100644 --- a/src/commands/Dashboard.ts +++ b/src/commands/Dashboard.ts @@ -341,7 +341,15 @@ export class Dashboard { selectedFolder = ''; } - const relSelectedFolderPath = selectedFolder ? selectedFolder.substring((parseWinPath(wsFolder?.fsPath || "")).length + 1) : ''; + let relSelectedFolderPath = selectedFolder; + const parsedPath = parseWinPath(wsFolder?.fsPath || ""); + if (selectedFolder && selectedFolder.startsWith(parsedPath)) { + relSelectedFolderPath = selectedFolder.replace(parsedPath, ''); + } + + if (relSelectedFolderPath.startsWith('/')) { + relSelectedFolderPath = relSelectedFolderPath.substring(1); + } let allMedia: MediaInfo[] = []; @@ -574,9 +582,9 @@ export class Dashboard { if (imgData) { writeFileSync(staticPath, imgData.data); - Notifications.info(`File ${fileName} uploaded to: ${staticFolder}/${folder}`); + Notifications.info(`File ${fileName} uploaded to: ${folder}`); - const folderPath = `${staticFolder}/${folder}`; + const folderPath = `${folder}`; if (Dashboard.timers[folderPath]) { clearTimeout(Dashboard.timers[folderPath]); delete Dashboard.timers[folderPath];