diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js index 2a4310ac0e2..f3a675da1f6 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js @@ -6,8 +6,9 @@ const HTML_TYPES = ["html_block", "html_inline"]; function addImage(uploads, token) { if (token.attrs) { for (let i = 0; i < token.attrs.length; i++) { - if (token.attrs[i][1].indexOf("upload://") === 0) { - uploads.push({ token, srcIndex: i, origSrc: token.attrs[i][1] }); + const value = token.attrs[i][1]; + if (value?.startsWith("upload://")) { + uploads.push({ token, srcIndex: i, origSrc: value }); break; } }