UNPKG

292 BJavaScriptView Raw
1import path from 'node:path';
2
3export default function isPathInside(childPath, parentPath) {
4 const relation = path.relative(parentPath, childPath);
5
6 return Boolean(
7 relation &&
8 relation !== '..' &&
9 !relation.startsWith(`..${path.sep}`) &&
10 relation !== path.resolve(childPath)
11 );
12}