(filePath: string)
| 44 | } |
| 45 | |
| 46 | export function assertPathAllowed(filePath: string): void { |
| 47 | const allowed = getAllowedPaths(); |
| 48 | if (!allowed) return; |
| 49 | const resolved = path.normalize(path.resolve(expandHome(filePath))); |
| 50 | if (!allowed.some((dir) => isWithinDirectory(resolved, dir))) { |
| 51 | throw new Error( |
| 52 | `Path "${filePath}" is outside the allowed directories. ` + |
| 53 | `Set MD_ALLOWED_PATHS to a ${path.delimiter}-separated list that includes a parent directory ` + |
| 54 | `(currently allowed: ${allowed.join(path.delimiter)}).`, |
| 55 | ); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | export function validateUrl(url: string): void { |
| 60 | const parsed = new URL(url); |
no test coverage detected