is-path-inside
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The "is-path-inside" is a Node.js package designed to check if a path is inside another path. This functionality allows developers to easily and quickly verify the relationship between two file paths, making it an essential tool for projects requiring path manipulation. It's important to note that while this package is extremely useful for path comparisons, it does not check if the paths exist nor does it resolve symlinks. Therefore, it should not be used as a security mechanism to guard against access to certain places on the file system.
To use "is-path-inside", first you'll need to install it by running npm install is-path-inside
in your terminal. You can then import it into your JavaScript file with import isPathInside from 'is-path-inside';
. The function takes two string arguments: the child path you want to test and the parent path you are testing against. Here are some usage examples:
import isPathInside from 'is-path-inside';
// checks if "a/b/c" is inside "a/b" - returns true
isPathInside('a/b/c', 'a/b');
// checks if "a/b/c" is inside "x/y" - returns false
isPathInside('a/b/c', 'x/y');
// checks if "/Users/sindresorhus/dev/unicorn" is inside "/Users/sindresorhus" - returns true
isPathInside('/Users/sindresorhus/dev/unicorn', '/Users/sindresorhus');
Remember that relative paths are resolved against process.cwd()
to make them absolute.
The "is-path-inside" documentation, which provides valuable information and examples on how to use the package, can be found in the readme file located on the GitHub repository page. Check it out here. A professional support for this package is available with a Tidelift subscription, which supports the open-source ecosystem while providing assurances about the security, maintenance, and licensing for dependency packages.