diff --git a/lib/index.umd.js b/lib/index.umd.js index 0732195..b4cea17 100644 --- a/lib/index.umd.js +++ b/lib/index.umd.js @@ -94,6 +94,10 @@ var walk = 0; while (level > 0 || walk === 0) { + if (walk >= src.length) { + return null; + } + if (src[walk] + src[walk + 1] === '$[') { level++; walk++; diff --git a/package.json b/package.json index eee9682..c7566f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "marked-mfm", - "version": "0.3.1", + "version": "0.3.2", "description": "Marked.js extension for Misskey-flavored Markdown", "main": "./src/index.js", "browser": "./lib/index.umd.js", diff --git a/src/index.js b/src/index.js index 6c07a70..c899aa3 100644 --- a/src/index.js +++ b/src/index.js @@ -10,6 +10,9 @@ export default { let level = 0 let walk = 0 while (level > 0 || walk === 0) { + if (walk >= src.length) { + return null + } if (src[walk] + src[walk + 1] === '$[') { level++ walk++