(notes: NoteRef[], target: string)
| 115 | } |
| 116 | |
| 117 | function 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 | |
| 132 | export function resolveWikilinkTarget<T extends NoteRef>(notes: T[], target: string): T | null { |
| 133 | // `[[Doc#Heading]]` / `[[Doc^block]]` point at a spot inside Doc — resolve the |
no test coverage detected