Skip to content

Commit cd74ba5

Browse files
author
Kyle Zhang
committed
Refactor key links section update logic to ensure proper content replacement and formatting
1 parent 9b43e5f commit cd74ba5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/rlc-common/src/metadata/buildReadmeFile.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,13 @@ function updateKeyLinksSection(
409409
existingContent: string,
410410
newKeyLinksSection: string
411411
): string {
412-
const keyLinksPattern = /Key links:\s*\n((?:(?:\n|.)*?)(?=\n## |\n# |$))/;
412+
// Match "Key links:" followed by content until the next section (## or #) or end of file
413+
const keyLinksPattern = /Key links:\s*\n[\s\S]*?(?=\n## |\n# |$)/;
413414

414415
if (existingContent.match(keyLinksPattern)) {
416+
// Replace the entire Key links section with the new content
415417
// Ensure there's a blank line after the Key links section
416-
const newKeyLinksWithBlankLine = newKeyLinksSection + "\n";
417-
return existingContent.replace(keyLinksPattern, newKeyLinksWithBlankLine);
418+
return existingContent.replace(keyLinksPattern, newKeyLinksSection + "\n");
418419
}
419420

420421
return existingContent;

0 commit comments

Comments
 (0)