Skip to content

Commit a99a794

Browse files
authored
Fixed advanced security warnings (#66)
Refactors the frontmatter parsing logic in the README update script. Removes redundant checks and simplifies the state management for identifying frontmatter sections, improving code readability and maintainability.
1 parent 1cfc840 commit a99a794

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

update-readme.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ function extractDescription(filePath) {
189189
// Parse frontmatter for description (for both prompts and instructions)
190190
const lines = content.split("\n");
191191
let inFrontmatter = false;
192-
let frontmatterEnded = false;
193192

194193
// For multi-line descriptions
195194
let isMultilineDescription = false;
@@ -201,14 +200,12 @@ function extractDescription(filePath) {
201200
if (line.trim() === "---") {
202201
if (!inFrontmatter) {
203202
inFrontmatter = true;
204-
} else if (inFrontmatter && !frontmatterEnded) {
205-
frontmatterEnded = true;
206-
break;
203+
continue;
207204
}
208-
continue;
205+
break;
209206
}
210207

211-
if (inFrontmatter && !frontmatterEnded) {
208+
if (inFrontmatter) {
212209
// Check for multi-line description with pipe syntax (|)
213210
const multilineMatch = line.match(/^description:\s*\|(\s*)$/);
214211
if (multilineMatch) {
@@ -221,7 +218,6 @@ function extractDescription(filePath) {
221218
if (isMultilineDescription) {
222219
// If the line has no indentation or has another frontmatter key, stop collecting
223220
if (!line.startsWith(" ") || line.match(/^[a-zA-Z0-9_-]+:/)) {
224-
isMultilineDescription = false;
225221
// Join the collected lines and return
226222
return multilineDescription.join(" ").trim();
227223
}

0 commit comments

Comments
 (0)