12 lines
292 B
JavaScript
12 lines
292 B
JavaScript
import path from 'node:path';
|
|
|
|
export default function isPathInside(childPath, parentPath) {
|
|
const relation = path.relative(parentPath, childPath);
|
|
|
|
return Boolean(
|
|
relation &&
|
|
relation !== '..' &&
|
|
!relation.startsWith(`..${path.sep}`) &&
|
|
relation !== path.resolve(childPath)
|
|
);
|
|
}
|