(notes: RenameNoteRef[], target: string)
| 35 | } |
| 36 | |
| 37 | function 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 | |
| 55 | function resolvePathSuffix(notes: RenameNoteRef[], target: string): RenameNoteRef | null { |
| 56 | const trimmed = stripMdExtension(normalizeSlashes(target.trim())) |
no test coverage detected