Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): skip doc headings when regex captures are missing

Richie McIlroy804b79d00524
diff --git a/apps/web/utils/docs.ts b/apps/web/utils/docs.ts
index d05eaf19d..cc50a41aa 100644
--- a/apps/web/utils/docs.ts
+++ b/apps/web/utils/docs.ts
@@ -96,8 +96,10 @@ export function extractHeadings(content: string): DocHeading[] {
const headingRegex = /^(#{2,3})\s+(.+)$/gm;
const headings: DocHeading[] = [];
for (const match of content.matchAll(headingRegex)) {
- const level = match[1]?.length;
+ const hashes = match[1];
const text = match[2]?.trim();
+ if (!hashes || text === undefined) continue;
+ const level = hashes.length;
const slug = text
.toLowerCase()
.replace(/\s+/g, "-")