(filePath: string)
| 79 | * Throws PathNotAllowedError if path is not allowed |
| 80 | */ |
| 81 | export function validatePath(filePath: string): string { |
| 82 | const resolvedPath = path.resolve(filePath); |
| 83 | |
| 84 | if (!isPathAllowed(resolvedPath)) { |
| 85 | throw new PathNotAllowedError(filePath); |
| 86 | } |
| 87 | |
| 88 | return resolvedPath; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Check if a path is within a directory, with protection against path traversal |
no test coverage detected