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

Function resolveExplicitPath

apps/desktop/src/main/wikilink-rename.ts:37–53  ·  view source on GitHub ↗
(notes: RenameNoteRef[], target: string)

Source from the content-addressed store, hash-verified

35}
36
37function resolveExplicitPath(notes: RenameNoteRef[], target: string): RenameNoteRef | null {
38 const normalized = normalizeSlashes(target.trim())
39 if (!normalized) return null
40 const trimmed = stripMdExtension(normalized).replace(/^\/+/, '').replace(/\/+$/, '')
41 if (!trimmed) return null
42
43 let relPath: string | null = null
44 if (normalized.startsWith('/')) {
45 relPath = `inbox/${trimmed}.md`
46 } else if (TOP_FOLDERS.some((folder) => trimmed.toLowerCase().startsWith(`${folder}/`))) {
47 relPath = `${trimmed}.md`
48 }
49 if (!relPath) return null
50
51 const needle = normalizeForCompare(relPath)
52 return notes.find((note) => normalizeForCompare(note.path) === needle) ?? null
53}
54
55function resolvePathSuffix(notes: RenameNoteRef[], target: string): RenameNoteRef | null {
56 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