Skip to content
Permalink
Browse files
Core: Fixed type error on null (#3057)
  • Loading branch information
RunDevelopment committed Oct 1, 2021
1 parent 8daebb4 commit a80a68ba507dae20f007a0817d9812f8eebcc5ce
Showing with 18 additions and 4 deletions.
  1. +1 −1 components/prism-core.js
  2. +1 −1 components/prism-core.min.js
  3. +1 −1 docs/prism-core.js.html
  4. +1 −1 prism.js
  5. +14 −0 tests/core/greedy.js
@@ -947,7 +947,7 @@ var Prism = (function (_self) {

if (greedy) {
match = matchPattern(pattern, pos, text, lookbehind);
if (!match) {
if (!match || match.index >= text.length) {
break;
}

Some generated files are not rendered by default. Learn more.

@@ -1000,7 +1000,7 @@ <h1 class="page-title">prism-core.js</h1>

if (greedy) {
match = matchPattern(pattern, pos, text, lookbehind);
if (!match) {
if (!match || match.index >= text.length) {
break;
}

@@ -952,7 +952,7 @@ var Prism = (function (_self) {

if (greedy) {
match = matchPattern(pattern, pos, text, lookbehind);
if (!match) {
if (!match || match.index >= text.length) {
break;
}

@@ -105,4 +105,18 @@ describe('Greedy matching', function () {
});
});

it('issue3052', function () {
// If a greedy pattern creates an empty token at the end of the string, then this token should be discarded
testTokens({
grammar: {
'oh-no': {
pattern: /$/,
greedy: true
}
},
code: 'foo',
expected: ['foo']
});
});

});

0 comments on commit a80a68b

Please sign in to comment.