(root: string, rel: string)
| 328 | } |
| 329 | |
| 330 | function resolveSafe(root: string, rel: string): string { |
| 331 | const abs = path.resolve(root, rel) |
| 332 | const rootAbs = path.resolve(root) |
| 333 | if (abs !== rootAbs && !abs.startsWith(rootAbs + path.sep)) { |
| 334 | throw new Error(`Path escapes vault: ${rel}`) |
| 335 | } |
| 336 | return abs |
| 337 | } |
| 338 | |
| 339 | function folderOf(root: string, abs: string): NoteFolder | null { |
| 340 | const rel = toPosix(path.relative(root, abs)) |
no outgoing calls
no test coverage detected