(root: string, rel: string)
| 2863 | } |
| 2864 | |
| 2865 | async function assertAssetFile(root: string, rel: string): Promise<{ rel: string; abs: string }> { |
| 2866 | const normalized = normalizeVaultRelativePath(rel) |
| 2867 | if (!normalized) throw new Error('Asset path is required.') |
| 2868 | if (normalized.split('/').includes(INTERNAL_VAULT_DIR)) { |
| 2869 | throw new Error('Cannot modify internal ZenNotes files.') |
| 2870 | } |
| 2871 | if (path.extname(normalized).toLowerCase() === '.md') { |
| 2872 | throw new Error('Use note actions to modify markdown notes.') |
| 2873 | } |
| 2874 | const abs = resolveSafe(root, normalized) |
| 2875 | const info = await fs.stat(abs) |
| 2876 | if (!info.isFile()) throw new Error('Asset path is not a file.') |
| 2877 | return { rel: normalized, abs } |
| 2878 | } |
| 2879 | |
| 2880 | function cleanAssetFilename(name: string): string { |
| 2881 | const raw = name.trim() |
no test coverage detected