MCPcopy
hub / github.com/claude-code-best/claude-code / parseFrontmatterPaths

Function parseFrontmatterPaths

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

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

Callers 1

parseMemoryFileContentFunction · 0.85

Calls 2

splitPathInFrontmatterFunction · 0.85
parseFrontmatterFunction · 0.70

Tested by

no test coverage detected