From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Thu, 11 Aug 2022 11:50:55 +0000 (+0530) Subject: Only render mxc images in markdown X-Git-Tag: v2.1.2~5 X-Git-Url: https://git.wafflesoft.org/?a=commitdiff_plain;h=258afec39134e33319a68c7839fe2248c6b58465;p=cinny.git Only render mxc images in markdown --- diff --git a/src/util/sanitize.js b/src/util/sanitize.js index ade47ff..0f88c62 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), }, }; }