( filePath: string, dir: string, )
| 3 | import { pathToFileUrl, relativeUrl } from "./file_url.ts"; |
| 4 | |
| 5 | export function assertInDir( |
| 6 | filePath: string, |
| 7 | dir: string, |
| 8 | ): void { |
| 9 | let tmp = filePath; |
| 10 | if (!path.isAbsolute(tmp)) { |
| 11 | tmp = path.join(dir, filePath); |
| 12 | } |
| 13 | |
| 14 | if (path.relative(dir, tmp).startsWith(".")) { |
| 15 | throw new Error(`Path "${tmp}" resolved outside of "${dir}"`); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Converts a file path to a valid JS export name. |
no outgoing calls
no test coverage detected