From 70cc2bb247b26d4571164865a634e140b2df61b0 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Thu, 30 Apr 2026 03:33:04 -0400 Subject: [PATCH] fix: accept crlf command frontmatter --- tests/commands/command-frontmatter.test.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/commands/command-frontmatter.test.js b/tests/commands/command-frontmatter.test.js index 06666c71..36d4714f 100644 --- a/tests/commands/command-frontmatter.test.js +++ b/tests/commands/command-frontmatter.test.js @@ -29,20 +29,17 @@ function getCommandFiles() { } function parseFrontmatter(content) { - if (!content.startsWith('---\n')) { - return null; - } - - const endIndex = content.indexOf('\n---', 4); - if (endIndex === -1) { - return null; - } - - return content.slice(4, endIndex); + const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/); + return match ? match[1] : null; } console.log('\n=== Testing command frontmatter metadata ===\n'); +test('frontmatter parser accepts LF and CRLF line endings', () => { + assert.strictEqual(parseFrontmatter('---\ndescription: ok\n---\n# Title'), 'description: ok'); + assert.strictEqual(parseFrontmatter('---\r\ndescription: ok\r\n---\r\n# Title'), 'description: ok'); +}); + for (const fileName of getCommandFiles()) { test(`${fileName} declares command metadata frontmatter`, () => { const content = fs.readFileSync(path.join(commandsDir, fileName), 'utf8');