MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / vaultRelativeNotePath

Function vaultRelativeNotePath

apps/desktop/src/main/file-open.ts:18–27  ·  view source on GitHub ↗
(vaultRoot: string, absPath: string)

Source from the content-addressed store, hash-verified

16 * absolute file from the OS gets mapped onto an open vault.
17 */
18export function vaultRelativeNotePath(vaultRoot: string, absPath: string): string | null {
19 const root = path.resolve(vaultRoot)
20 const target = path.resolve(absPath)
21 if (target === root) return null
22 const rel = path.relative(root, target)
23 if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return null
24 const segments = rel.split(path.sep)
25 if (segments.some((segment) => segment === '..')) return null
26 return segments.join('/')
27}
28
29export type MarkdownOpenTarget =
30 | { kind: 'vault'; vaultRoot: string; relPath: string }

Callers 2

file-open.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected