(workspaceDir, requestedPath)
| 377 | } |
| 378 | |
| 379 | function resolveWorkspacePath(workspaceDir, requestedPath) { |
| 380 | const absoluteWorkspace = path.resolve(workspaceDir) |
| 381 | const candidate = path.resolve(absoluteWorkspace, requestedPath) |
| 382 | const relative = path.relative(absoluteWorkspace, candidate) |
| 383 | |
| 384 | if (relative.startsWith('..') || path.isAbsolute(relative)) { |
| 385 | throw new Error(`Path escapes workspace: ${requestedPath}`) |
| 386 | } |
| 387 | |
| 388 | return candidate |
| 389 | } |
| 390 | |
| 391 | function toWorkspaceRelative(workspaceDir, absolutePath) { |
| 392 | const relative = path.relative(workspaceDir, absolutePath) |
no outgoing calls
no test coverage detected