diff --git a/ci/checkLinks.ts b/ci/checkLinks.ts index 46b4a5357f..3498188a2b 100644 --- a/ci/checkLinks.ts +++ b/ci/checkLinks.ts @@ -75,6 +75,14 @@ function annotateResults(resultMap: Map): } } +function* concatIterables(...iterables: IterableIterator[]) { + for (const iterable of iterables) { + for (const value of iterable) { + yield value; + } + } +} + const docFiles = importDirectory(path.join(cwd, "docs"), [".md", ".mdx"]); if (!docFiles) { @@ -136,10 +144,11 @@ for (const [name, raw] of docFiles) { if (line.trim().length > 3 && line.trim().endsWith("```")) multilineCode = !multilineCode; } if (multilineCode) return; - const matches = line.matchAll(/(?.+?)\)(?!`)/g); + const componentMatches = line.matchAll(/(?:link|href)="(?!https?|mailto)(?.+?)"/g); - for (const match of matches) { - const split = match[1].split("#")[1].split("/"); + for (const match of concatIterables(markdownMatches, componentMatches)) { + const split = match.groups!.link.split("#")[1].split("/"); const page = split[0]; const anchor = split[1]; if (!validLinks.has(page)) {