diff --git a/index.js b/index.js index 8d8e19f..c44c7cf 100644 --- a/index.js +++ b/index.js @@ -57,6 +57,12 @@ function test(tokens, i, t) { let ii = t.shift !== undefined ? i + t.shift : t.position; + + if (t.shift !== undefined && ii < 0) { + // we should never shift to negative indexes (rolling around to back of array) + return res; + } + let token = get(tokens, ii); // supports negative ii diff --git a/test.js b/test.js index bffdae9..a25ca18 100644 --- a/test.js +++ b/test.js @@ -390,11 +390,17 @@ function describeTestsWithOptions(options, postText) { assert.equal(md.render(replaceDelimiters(src, options)), expected); }); - it(replaceDelimiters('should support multiple classes for