Skip to content

Commit

Permalink
Satisfy sonar about infinite loop risk
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl committed Oct 29, 2024
1 parent 94daa5e commit 944cb34
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ function findStreamingSections(message: Message | undefined): {
const { content } = message;
const pathMatches: RegExpExecArray[] = [];
let match: RegExpExecArray | null;
while ((match = /"path":"\/([^/"]*)(?:\/|")/g.exec(content)) !== null) {
const regex = /"path":"\/([^/"]*)(?:\/|")"/g;
let startIndex = 0;
while ((match = regex.exec(content.slice(startIndex))) !== null) {
pathMatches.push(match);
startIndex += match.index + match[0].length;
if (pathMatches.length > 100) {
log.warn("Too many path matches found, stopping search");
break;
}
}

const streamingSections: LessonPlanKeys[] = pathMatches
Expand Down

0 comments on commit 944cb34

Please sign in to comment.