* 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)
| 102 | * case than the lexical root, which would otherwise false-reject a valid file. |
| 103 | */ |
| 104 | function isWithinDir(child: string, parent: string): boolean { |
| 105 | if (process.platform === 'win32') { |
| 106 | return isSameOrUnder(child.toLowerCase(), parent.toLowerCase()); |
| 107 | } |
| 108 | return isSameOrUnder(child, parent); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * The lexical half of {@link validatePathWithinRoot}, on its own. |
no test coverage detected