mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 05:05:39 +00:00
fix: prevent URL marking within variable patterns in CodeMirror (#6680)
This commit is contained in:
committed by
GitHub
parent
4c110900c1
commit
bc0bb64400
@@ -59,7 +59,18 @@ function markUrls(editor, linkify, linkClass, linkHint) {
|
||||
const matches = linkify.match(lineContent);
|
||||
if (!matches) continue;
|
||||
|
||||
const variablePatterns = [];
|
||||
const variablePattern = /\{\{[^}]*\}\}/g;
|
||||
let varMatch;
|
||||
while ((varMatch = variablePattern.exec(lineContent)) !== null) {
|
||||
variablePatterns.push({ start: varMatch.index, end: varMatch.index + varMatch[0].length });
|
||||
}
|
||||
matches.forEach(({ index, lastIndex, url }) => {
|
||||
const isInVariable = variablePatterns.some(
|
||||
({ start, end }) => index < end && lastIndex > start
|
||||
);
|
||||
if (isInVariable) return;
|
||||
|
||||
try {
|
||||
editor.markText(
|
||||
{ line: lineNum, ch: index },
|
||||
|
||||
Reference in New Issue
Block a user