Skip to content

Commit c539266

Browse files
committed
Resolved a potential extra slash in path name
This was preventing downloads of images in subfolders in chromium browsers Should fix #89, #78 and #34 (hopefully)
1 parent 918e345 commit c539266

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/background/background.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ async function downloadMarkdown(markdown, title, tabId, imageList = {}, mdClipsF
357357
}));
358358

359359
try {
360+
361+
if(mdClipsFolder && !mdClipsFolder.endsWith('/')) mdClipsFolder += '/';
360362
// start the download
361363
const id = await browser.downloads.download({
362364
url: url,
@@ -371,12 +373,13 @@ async function downloadMarkdown(markdown, title, tabId, imageList = {}, mdClipsF
371373
if (options.downloadImages) {
372374
// get the relative path of the markdown file (if any) for image path
373375
const destPath = mdClipsFolder + title.substring(0, title.lastIndexOf('/'));
376+
if(destPath && !destPath.endsWith('/')) destPath += '/';
374377
Object.entries(imageList).forEach(async ([src, filename]) => {
375378
// start the download of the image
376379
const imgId = await browser.downloads.download({
377380
url: src,
378381
// set a destination path (relative to md file)
379-
filename: destPath ? destPath + '/' + filename : filename,
382+
filename: destPath ? destPath + filename : filename,
380383
saveAs: false
381384
})
382385
// add a listener (so we can release the blob url)

0 commit comments

Comments
 (0)