MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseFrontmatterPaths

Function parseFrontmatterPaths

src/utils/claudemd.ts:260–285  ·  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

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