MCPcopy Create free account
hub / github.com/QuantiaAI/helm-agents / resolveDocPath

Function resolveDocPath

apps/api/src/lib/docs.ts:24–34  ·  view source on GitHub ↗
(
  slug: string[],
  root: string = docsRoot(),
)

Source from the content-addressed store, hash-verified

22 * slug is empty, not a `.md` file, or escapes the root (path-traversal guard).
23 */
24export function resolveDocPath(
25 slug: string[],
26 root: string = docsRoot(),
27): string | null {
28 if (!slug.length) return null;
29 const rel = slug.join("/");
30 if (!rel.endsWith(".md")) return null;
31 const abs = resolve(root, rel);
32 if (abs !== root && !abs.startsWith(root + sep)) return null;
33 return abs;
34}
35
36/** Read a doc by slug, or null if the slug is invalid or the file is missing. */
37export function readDoc(slug: string[]): string | null {

Callers 2

readDocFunction · 0.85
docs.spec.tsFile · 0.85

Calls 1

docsRootFunction · 0.85

Tested by

no test coverage detected