main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | # is-path-inside
|
---|
2 |
|
---|
3 | > Check if a path is inside another path
|
---|
4 |
|
---|
5 |
|
---|
6 | ## Install
|
---|
7 |
|
---|
8 | ```
|
---|
9 | $ npm install is-path-inside
|
---|
10 | ```
|
---|
11 |
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | const isPathInside = require('is-path-inside');
|
---|
17 |
|
---|
18 | isPathInside('a/b/c', 'a/b');
|
---|
19 | //=> true
|
---|
20 |
|
---|
21 | isPathInside('a/b/c', 'x/y');
|
---|
22 | //=> false
|
---|
23 |
|
---|
24 | isPathInside('a/b/c', 'a/b/c');
|
---|
25 | //=> false
|
---|
26 |
|
---|
27 | isPathInside('/Users/sindresorhus/dev/unicorn', '/Users/sindresorhus');
|
---|
28 | //=> true
|
---|
29 | ```
|
---|
30 |
|
---|
31 |
|
---|
32 | ## API
|
---|
33 |
|
---|
34 | ### isPathInside(childPath, parentPath)
|
---|
35 |
|
---|
36 | Note that relative paths are resolved against `process.cwd()` to make them absolute.
|
---|
37 |
|
---|
38 | **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.
|
---|
39 |
|
---|
40 | #### childPath
|
---|
41 |
|
---|
42 | Type: `string`
|
---|
43 |
|
---|
44 | The path that should be inside `parentPath`.
|
---|
45 |
|
---|
46 | #### parentPath
|
---|
47 |
|
---|
48 | Type: `string`
|
---|
49 |
|
---|
50 | The path that should contain `childPath`.
|
---|
51 |
|
---|
52 |
|
---|
53 | ---
|
---|
54 |
|
---|
55 | <div align="center">
|
---|
56 | <b>
|
---|
57 | <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>
|
---|
58 | </b>
|
---|
59 | <br>
|
---|
60 | <sub>
|
---|
61 | Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
---|
62 | </sub>
|
---|
63 | </div>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.