MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseFrontmatterPaths

Function parseFrontmatterPaths

src/utils/claudemd.ts:254–279  ·  view source on GitHub ↗

* Parses raw content to extract both content and glob patterns from frontmatter * @param rawContent Raw file content with frontmatter * @returns Object with content and globs (undefined if no paths or match-all pattern)

(rawContent: string)

Source from the content-addressed store, hash-verified

252 * @returns Object with content and globs (undefined if no paths or match-all pattern)
253 */
254function parseFrontmatterPaths(rawContent: string): {
255 content: string
256 paths?: string[]
257} {
258 const { frontmatter, content } = parseFrontmatter(rawContent)
259
260 if (!frontmatter.paths) {
261 return { content }
262 }
263
264 const patterns = splitPathInFrontmatter(frontmatter.paths)
265 .map(pattern => {
266 // Remove /** suffix - ignore library treats 'path' as matching both
267 // the path itself and everything inside it
268 return pattern.endsWith('/**') ? pattern.slice(0, -3) : pattern
269 })
270 .filter((p: string) => p.length > 0)
271
272 // If all patterns are ** (match-all), treat as no globs (undefined)
273 // This means the file applies to all paths
274 if (patterns.length === 0 || patterns.every((p: string) => p === '**')) {
275 return { content }
276 }
277
278 return { content, paths: patterns }
279}
280
281/**
282 * Strip block-level HTML comments (<!-- ... -->) from markdown content.

Callers 1

parseMemoryFileContentFunction · 0.85

Calls 2

parseFrontmatterFunction · 0.85
splitPathInFrontmatterFunction · 0.85

Tested by

no test coverage detected