diff --git a/src/common/text/elements/code.js b/src/common/text/elements/code.js index 9c0ea8a4fb..6daf141342 100644 --- a/src/common/text/elements/code.js +++ b/src/common/text/elements/code.js @@ -140,7 +140,9 @@ const elements = [ // comment code => { if (code.substr(0, 2) != '//') return null; - const comment = code.match(/^\/\/(.+?)\n/)[0]; + const match = code.match(/^\/\/(.+?)\n/); + if (!match) return null; + const comment = match[0]; return { html: `${escape(comment)}`, next: comment.length