(notes: NoteRef[], target: string)
| 96 | } |
| 97 | |
| 98 | function 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 | |
| 117 | function resolvePathSuffix(notes: NoteRef[], target: string): NoteRef | null { |
| 118 | const trimmed = stripMdExtension(normalizeSlashes(target.trim())) |
no test coverage detected