UNPKG

1.36 kBMarkdownView Raw
1# is-path-inside
2
3> Check if a path is inside another path
4
5## Install
6
7```
8$ npm install is-path-inside
9```
10
11## Usage
12
13```js
14import isPathInside from 'is-path-inside';
15
16isPathInside('a/b/c', 'a/b');
17//=> true
18
19isPathInside('a/b/c', 'x/y');
20//=> false
21
22isPathInside('a/b/c', 'a/b/c');
23//=> false
24
25isPathInside('/Users/sindresorhus/dev/unicorn', '/Users/sindresorhus');
26//=> true
27```
28
29## API
30
31### isPathInside(childPath, parentPath)
32
33Note that relative paths are resolved against `process.cwd()` to make them absolute.
34
35**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.
36
37#### childPath
38
39Type: `string`
40
41The path that should be inside `parentPath`.
42
43#### parentPath
44
45Type: `string`
46
47The path that should contain `childPath`.
48
49---
50
51<div align="center">
52 <b>
53 <a href="https://tidelift.com/subscription/pkg/npm-is-path-inside?utm_source=npm-is-path-inside&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
54 </b>
55 <br>
56 <sub>
57 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
58 </sub>
59</div>