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

Function resolvePathSuffix

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

Source from the content-addressed store, hash-verified

115}
116
117function resolvePathSuffix(notes: NoteRef[], target: string): NoteRef | null {
118 const trimmed = stripMdExtension(normalizeSlashes(target.trim()))
119 .replace(/^\/+/, '')
120 .replace(/\/+$/, '')
121 if (!trimmed) return null
122
123 const suffix = normalizeForCompare(`/${trimmed}.md`)
124 const exact = normalizeForCompare(`${trimmed}.md`)
125 const matches = notes.filter((note) => {
126 const path = normalizeForCompare(note.path)
127 return path === exact || path.endsWith(suffix)
128 })
129 return matches.length === 1 ? matches[0] : null
130}
131
132export function resolveWikilinkTarget<T extends NoteRef>(notes: T[], target: string): T | null {
133 // `[[Doc#Heading]]` / `[[Doc^block]]` point at a spot inside Doc — resolve the

Callers 1

resolveWikilinkTargetFunction · 0.70

Calls 3

stripMdExtensionFunction · 0.70
normalizeSlashesFunction · 0.70
normalizeForCompareFunction · 0.70

Tested by

no test coverage detected