From 258afec39134e33319a68c7839fe2248c6b58465 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Thu, 11 Aug 2022 17:20:55 +0530 Subject: [PATCH] Only render mxc images in markdown --- src/util/sanitize.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/util/sanitize.js b/src/util/sanitize.js index ade47ffc..0f88c62b 100644 --- a/src/util/sanitize.js +++ b/src/util/sanitize.js @@ -76,11 +76,22 @@ function transformATag(tagName, attribs) { function transformImgTag(tagName, attribs) { const { src } = attribs; + if (src.startsWith('mxc://') === false) { + return { + tagName: 'a', + attribs: { + href: src, + rel: 'noopener', + target: '_blank', + }, + text: attribs.alt || src, + }; + } return { tagName, attribs: { ...attribs, - src: src.startsWith('mxc://') ? mx?.mxcUrlToHttp(src) : src, + src: mx?.mxcUrlToHttp(src), }, }; }