Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 08:15 UTC
fix: use github-slugger instead of custom slugify
Replaces custom regex slugify with github-slugger to correctly handle Unicode characters and duplicate heading suffixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmithamallesh committed
Feb 17, 2026 at 20:19 UTC
e6c2cb079289846552d19533c0f85eaa95b6fae2
1 file changed
+4
-13
docs/scripts/validate-links.ts
+4
-13
@@ -7,6 +7,7 @@ import {
7
scanURLs,
8
validateFiles,
9
} from 'next-validate-link';
10
+import GithubSlugger from 'github-slugger';
11
import {
12
source,
13
getReferenceSource,
@@ -22,28 +23,18 @@ type AnySource =
23
24
type PageOf = ReturnType<AnySource['getPages']>[number];
25
25
-/**
26
- * Slugify a heading the same way rehype-slug does.
27
- */
28
-function slugify(text: string): string {
29
- return text
30
- .toLowerCase()
31
- .replace(/[^\w\s-]/g, '')
32
- .replace(/[\s]+/g, '-')
33
- .replace(/-+/g, '-')
34
- .replace(/^-|-$/g, '');
35
-}
36
-
26
/**
27
* Extract heading anchors from raw MDX/markdown content.
28
* Falls back to this when data.toc is unavailable (outside Next.js runtime).
29
+ * Uses github-slugger to match rehype-slug's algorithm (handles Unicode, duplicate suffixes).
30
*/
31
function extractHeadingsFromContent(content: string): string[] {
32
+ const slugger = new GithubSlugger();
33
const headings: string[] = [];
34
for (const line of content.split('\n')) {
35
const match = line.match(/^#{1,6}\s+(.+)$/);
36
if (match) {
46
- headings.push(slugify(match[1]));
37
+ headings.push(slugger.slug(match[1]));
38
}
39
}
40
return headings;