diff --git a/markdown-it-attrs.browser.js b/markdown-it-attrs.browser.js index 93cb7fd..5e2db6a 100644 --- a/markdown-it-attrs.browser.js +++ b/markdown-it-attrs.browser.js @@ -69,6 +69,12 @@ function test(tokens, i, t) { }; var 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; + } + var token = get(tokens, ii); // supports negative ii if (token === undefined) { diff --git a/package-lock.json b/package-lock.json index adfc1c3..c5f978b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "markdown-it-attrs", - "version": "4.1.2", + "version": "4.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "markdown-it-attrs", - "version": "4.1.2", + "version": "4.1.3", "license": "MIT", "devDependencies": { "@babel/core": "^7.15.5", diff --git a/package.json b/package.json index 6bafd24..d3ce6ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "markdown-it-attrs", - "version": "4.1.2", + "version": "4.1.3", "description": "Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes", "main": "index.js", "license": "MIT",