(targetPath: string, rootPath: string)
| 54 | } |
| 55 | |
| 56 | export function isPathWithinRoot(targetPath: string, rootPath: string): boolean { |
| 57 | const resolvedTarget = path.resolve(targetPath) |
| 58 | const resolvedRoot = path.resolve(rootPath) |
| 59 | return resolvedTarget === resolvedRoot || resolvedTarget.startsWith(resolvedRoot + path.sep) |
| 60 | } |
| 61 | |
| 62 | export function resolveRelativePathWithinRoot(rootPath: string, relativePath: string): string { |
| 63 | const normalizedRelativePath = path.normalize(relativePath) |
no outgoing calls
no test coverage detected