用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB

6 months ago
  1. # is-path-inside
  2. > Check if a path is inside another path
  3. ## Install
  4. ```
  5. $ npm install is-path-inside
  6. ```
  7. ## Usage
  8. ```js
  9. const isPathInside = require('is-path-inside');
  10. isPathInside('a/b/c', 'a/b');
  11. //=> true
  12. isPathInside('a/b/c', 'x/y');
  13. //=> false
  14. isPathInside('a/b/c', 'a/b/c');
  15. //=> false
  16. isPathInside('/Users/sindresorhus/dev/unicorn', '/Users/sindresorhus');
  17. //=> true
  18. ```
  19. ## API
  20. ### isPathInside(childPath, parentPath)
  21. Note that relative paths are resolved against `process.cwd()` to make them absolute.
  22. **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.
  23. #### childPath
  24. Type: `string`
  25. The path that should be inside `parentPath`.
  26. #### parentPath
  27. Type: `string`
  28. The path that should contain `childPath`.
  29. ---
  30. <div align="center">
  31. <b>
  32. <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>
  33. </b>
  34. <br>
  35. <sub>
  36. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  37. </sub>
  38. </div>