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

Function resolveExplicitPath

packages/app-core/src/lib/wikilinks.ts:98–115  ·  view source on GitHub ↗
(notes: NoteRef[], target: string)

Source from the content-addressed store, hash-verified

96}
97
98function resolveExplicitPath(notes: NoteRef[], target: string): NoteRef | null {
99 const normalized = normalizeSlashes(target.trim())
100 if (!normalized) return null
101
102 const trimmed = stripMdExtension(normalized).replace(/^\/+/, '').replace(/\/+$/, '')
103 if (!trimmed) return null
104
105 let relPath: string | null = null
106 if (normalized.startsWith('/')) {
107 relPath = `inbox/${trimmed}.md`
108 } else if (TOP_FOLDERS.some((folder) => trimmed.toLowerCase().startsWith(`${folder}/`))) {
109 relPath = `${trimmed}.md`
110 }
111
112 if (!relPath) return null
113 const needle = normalizeForCompare(relPath)
114 return notes.find((note) => normalizeForCompare(note.path) === needle) ?? null
115}
116
117function resolvePathSuffix(notes: NoteRef[], target: string): NoteRef | null {
118 const trimmed = stripMdExtension(normalizeSlashes(target.trim()))

Callers 1

resolveWikilinkTargetFunction · 0.70

Calls 3

normalizeSlashesFunction · 0.70
stripMdExtensionFunction · 0.70
normalizeForCompareFunction · 0.70

Tested by

no test coverage detected