From 10043cc755ad18fa332258040540c703b05c3e13 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sun, 19 Mar 2017 21:43:54 -0700 Subject: [PATCH] Fix to handle when codeBlocks is null --- browser/components/MarkdownPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index 70d86819..863a3054 100644 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -260,7 +260,7 @@ export default class MarkdownPreview extends React.Component { this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme) const codeBlocks = value.match(/(```)(.|[\n])*?(```)/g) - if (codeBlocks.length > 0) { + if (codeBlocks !== null && codeBlocks.length > 0) { codeBlocks.forEach((codeBlock) => { const encodedCodeBlock = encodeHTMLEntities(codeBlock) value = value.replace(codeBlock, encodedCodeBlock)