diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 995542a0..1714e281 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -193,7 +193,7 @@ export default class CodeEditor extends React.Component { const filename = path.basename(imagePath) copyImage(imagePath, this.props.storageKey).then((imagePathInTheStorage) => { - const imageMd = `![${encodeURI(filename)}](${imagePathInTheStorage})` + const imageMd = `![${filename}](${imagePathInTheStorage})` this.insertImageMd(imageMd) }) } diff --git a/browser/main/lib/dataApi/copyImage.js b/browser/main/lib/dataApi/copyImage.js index 8c6f1787..dfd72476 100644 --- a/browser/main/lib/dataApi/copyImage.js +++ b/browser/main/lib/dataApi/copyImage.js @@ -19,10 +19,12 @@ function copyImage (filePath, storageKey) { const targetStorage = storage const inputImage = fs.createReadStream(filePath) - const imageName = path.basename(filePath) - const outputImage = fs.createWriteStream(path.join(targetStorage.path, 'images', imageName)) + const imageExt = path.extname(filePath) + const imageName = Math.random().toString(36).slice(-16) + const basename = `${imageName}${imageExt}` + const outputImage = fs.createWriteStream(path.join(targetStorage.path, 'images', basename)) inputImage.pipe(outputImage) - resolve(`${encodeURI(targetStorage.path)}/images/${encodeURI(imageName)}`) + resolve(`${targetStorage.path}/images/${basename}`) } catch (e) { return reject(e) }