mirror of
https://github.com/discourse/discourse.git
synced 2025-02-12 14:24:54 +00:00
FIX: Avoid String.matchAll for IE11 support
This commit is contained in:
parent
ea05a68df7
commit
d9e7611910
@ -422,17 +422,18 @@ const CODE_BLOCKS_REGEX = /^( |\t).*|`[^`]+`|^```[^]*?^```|\[code\][^]*?\[\/c
|
|||||||
// +------- paragraphs starting with 4 spaces or tab
|
// +------- paragraphs starting with 4 spaces or tab
|
||||||
|
|
||||||
export function inCodeBlock(text, pos) {
|
export function inCodeBlock(text, pos) {
|
||||||
const matches = text.matchAll(CODE_BLOCKS_REGEX);
|
let result = false;
|
||||||
|
|
||||||
for (const match of matches) {
|
let match;
|
||||||
|
while ((match = CODE_BLOCKS_REGEX.exec(text)) !== null) {
|
||||||
const begin = match.index;
|
const begin = match.index;
|
||||||
const end = match.index + match[0].length;
|
const end = match.index + match[0].length;
|
||||||
if (begin <= pos && pos <= end) {
|
if (begin <= pos && pos <= end) {
|
||||||
return true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This prevents a mini racer crash
|
// This prevents a mini racer crash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user