From 850561613ba2598ddfee1ecdb49548a85f40f7ae Mon Sep 17 00:00:00 2001
From: Baptiste Augrain
Date: Thu, 23 May 2019 21:58:01 +0200
Subject: [PATCH] fix gallery on windows
---
browser/lib/markdown.js | 5 +++--
tests/dataApi/attachmentManagement.test.js | 10 +++++++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/browser/lib/markdown.js b/browser/lib/markdown.js
index 5fd7c85c..2dc98121 100644
--- a/browser/lib/markdown.js
+++ b/browser/lib/markdown.js
@@ -2,6 +2,7 @@ import markdownit from 'markdown-it'
import sanitize from './markdown-it-sanitize-html'
import emoji from 'markdown-it-emoji'
import math from '@rokt33r/markdown-it-math'
+import mdurl from 'mdurl'
import smartArrows from 'markdown-it-smartarrows'
import _ from 'lodash'
import ConfigManager from 'browser/main/lib/ConfigManager'
@@ -150,9 +151,9 @@ class Markdown {
const content = token.content.split('\n').slice(0, -1).map(line => {
const match = /!\[[^\]]*]\(([^\)]*)\)/.exec(line)
if (match) {
- return match[1]
+ return mdurl.encode(match[1])
} else {
- return line
+ return mdurl.encode(line)
}
}).join('\n')
diff --git a/tests/dataApi/attachmentManagement.test.js b/tests/dataApi/attachmentManagement.test.js
index 800159b8..96394d9f 100644
--- a/tests/dataApi/attachmentManagement.test.js
+++ b/tests/dataApi/attachmentManagement.test.js
@@ -287,7 +287,11 @@ it('should replace the all ":storage" path with the actual storage path', functi
'
\n' +
' \n' +
' \n' +
- ' :storage' + mdurl.encode(path.sep) + noteKey + mdurl.encode(path.sep) + 'f939b2c3.jpg
\n' +
+ ' :storage' + mdurl.encode(path.win32.sep) + noteKey + mdurl.encode(path.win32.sep) + 'f939b2c3.jpg
\n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' :storage' + mdurl.encode(path.posix.sep) + noteKey + mdurl.encode(path.posix.sep) + 'f939b2c3.jpg
\n' +
'
\n' +
'