(parent: string, child: string)
| 32 | * 判断 child 是否为 parent 的子目录 |
| 33 | */ |
| 34 | export function isSubPath(parent: string, child: string): boolean { |
| 35 | const parentPath = normalizePathForCompare(parent) |
| 36 | const childPath = normalizePathForCompare(child) |
| 37 | |
| 38 | if (parentPath === childPath) return false |
| 39 | return childPath.startsWith(`${parentPath}${path.sep}`) |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * 检查路径是否安全(不在系统关键目录下) |
no test coverage detected