(target: string)
| 199 | } |
| 200 | |
| 201 | export function suggestCreateNotePath(target: string): string { |
| 202 | // Creating from `[[Doc#Heading]]` makes `Doc`, not the invalid `Doc#Heading`. (#196) |
| 203 | const trimmed = normalizeSlashes(stripWikilinkAnchor(target).trim()).replace(/\/+$/, '') |
| 204 | if (!trimmed) return '/Untitled.md' |
| 205 | |
| 206 | if (trimmed.startsWith('/')) { |
| 207 | return /\.md$/i.test(trimmed) ? trimmed : `${stripMdExtension(trimmed)}.md` |
| 208 | } |
| 209 | if (TOP_FOLDERS.some((folder) => trimmed.toLowerCase().startsWith(`${folder}/`))) { |
| 210 | return /\.md$/i.test(trimmed) ? trimmed : `${stripMdExtension(trimmed)}.md` |
| 211 | } |
| 212 | if (trimmed.includes('/')) { |
| 213 | return `/${stripMdExtension(trimmed)}.md` |
| 214 | } |
| 215 | return `/${stripMdExtension(trimmed)}.md` |
| 216 | } |
| 217 | |
| 218 | export function parseCreateNotePath(input: string): { |
| 219 | folder: NoteFolder |
no test coverage detected