UNPKG

735 BTypeScriptView Raw
1/**
2Check if a path is inside another path.
3
4Note that relative paths are resolved against `process.cwd()` to make them absolute.
5
6_Important:_ This package is meant for use with path manipulation. It does not check if the paths exist nor does it resolve symlinks. You should not use this as a security mechanism to guard against access to certain places on the file system.
7
8@example
9```
10import isPathInside from 'is-path-inside';
11
12isPathInside('a/b/c', 'a/b');
13//=> true
14
15isPathInside('a/b/c', 'x/y');
16//=> false
17
18isPathInside('a/b/c', 'a/b/c');
19//=> false
20
21isPathInside('/Users/sindresorhus/dev/unicorn', '/Users/sindresorhus');
22//=> true
23```
24*/
25export default function isPathInside(childPath: string, parentPath: string): boolean;