Skip to content

Commit 3e991d4

Browse files
committed
fix images with space in file name
1 parent 53ecbba commit 3e991d4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/components/EditorEasyMDE.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ export default {
190190
}
191191
const label = basename(path)
192192
const relativePath = relative(currentNotePath, path)
193-
doc.replaceRange('![' + label + '](' + relativePath + ')\n', { line: cursor.line })
193+
const encodedPath = relativePath.split('/').map(encodeURIComponent).join('/')
194+
doc.replaceRange('![' + label + '](' + encodedPath + ')\n', { line: cursor.line })
194195
this.mde.codemirror.focus()
195196
},
196197
false,

src/components/EditorMarkdownIt.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ export default {
7272
) {
7373
path = path.split('?').shift()
7474
const lowecasePath = path.toLowerCase()
75-
path = generateUrl('apps/notes/notes/{id}/attachment?path={path}', { id, path })
75+
path = generateUrl(
76+
'apps/notes/notes/{id}/attachment?path={path}',
77+
{ id, path: decodeURIComponent(path) },
78+
)
7679
token.attrs[aIndex][1] = path
7780
7881
if (!lowecasePath.endsWith('.jpg')

0 commit comments

Comments
 (0)