* Whether `child` is `parent` itself or sits underneath it. Case-insensitive on * Windows — NTFS is case-insensitive, and realpathSync can hand back a different * case than the lexical root, which would otherwise false-reject a valid file.
(child: string, parent: string)
| 101 | * case than the lexical root, which would otherwise false-reject a valid file. |
| 102 | */ |
| 103 | function isWithinDir(child: string, parent: string): boolean { |
| 104 | if (process.platform === 'win32') { |
| 105 | return isSameOrUnder(child.toLowerCase(), parent.toLowerCase()); |
| 106 | } |
| 107 | return isSameOrUnder(child, parent); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * The lexical half of {@link validatePathWithinRoot}, on its own. |
no test coverage detected