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.
This commit is contained in:
NULLchimp 2025-07-10 01:34:05 +02:00 committed by GitHub
parent 1cfc8401b2
commit a99a79441a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -189,7 +189,6 @@ function extractDescription(filePath) {
// Parse frontmatter for description (for both prompts and instructions) // Parse frontmatter for description (for both prompts and instructions)
const lines = content.split("\n"); const lines = content.split("\n");
let inFrontmatter = false; let inFrontmatter = false;
let frontmatterEnded = false;
// For multi-line descriptions // For multi-line descriptions
let isMultilineDescription = false; let isMultilineDescription = false;
@ -201,14 +200,12 @@ function extractDescription(filePath) {
if (line.trim() === "---") { if (line.trim() === "---") {
if (!inFrontmatter) { if (!inFrontmatter) {
inFrontmatter = true; inFrontmatter = true;
} else if (inFrontmatter && !frontmatterEnded) { continue;
frontmatterEnded = true;
break;
} }
continue; break;
} }
if (inFrontmatter && !frontmatterEnded) { if (inFrontmatter) {
// Check for multi-line description with pipe syntax (|) // Check for multi-line description with pipe syntax (|)
const multilineMatch = line.match(/^description:\s*\|(\s*)$/); const multilineMatch = line.match(/^description:\s*\|(\s*)$/);
if (multilineMatch) { if (multilineMatch) {
@ -221,7 +218,6 @@ function extractDescription(filePath) {
if (isMultilineDescription) { if (isMultilineDescription) {
// If the line has no indentation or has another frontmatter key, stop collecting // If the line has no indentation or has another frontmatter key, stop collecting
if (!line.startsWith(" ") || line.match(/^[a-zA-Z0-9_-]+:/)) { if (!line.startsWith(" ") || line.match(/^[a-zA-Z0-9_-]+:/)) {
isMultilineDescription = false;
// Join the collected lines and return // Join the collected lines and return
return multilineDescription.join(" ").trim(); return multilineDescription.join(" ").trim();
} }