Skip to content

Commit eba46bb

Browse files
committed
update metadata search
1 parent aa43fbc commit eba46bb

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/review-scripts.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,21 @@ async function reviewPR() {
8282
if (hasMetadata(content)) {
8383
// find the line number of the first two "---"
8484
const metadataStart = content.indexOf('---');
85-
const metadataEnd = content.indexOf('---', metadataStart + 3);
85+
// Find the line number of the second '---'
86+
let metadataEnd = -1;
87+
if (metadataStart !== -1) {
88+
const lines = content.split('\n');
89+
let dashCount = 0;
90+
for (let i = 0; i < lines.length; i++) {
91+
if (lines[i].trim() === '---') {
92+
dashCount++;
93+
if (dashCount === 2) {
94+
metadataEnd = i + 1;
95+
break;
96+
}
97+
}
98+
}
99+
}
86100
console.log(metadataStart, metadataEnd);
87101
reviewBody = `\`\`\`suggestion\n${suggestion}\n\`\`\`\n`;
88102

0 commit comments

Comments
 (0)