is-path-inside

Check if a path is inside another path

MIT 10 个版本
安装
npm install is-path-inside
yarn add is-path-inside
pnpm add is-path-inside
bun add is-path-inside
README

is-path-inside

Check if a path is inside another path

Install

$ npm install is-path-inside

Usage

import isPathInside from 'is-path-inside';

isPathInside('a/b/c', 'a/b');
//=> true

isPathInside('a/b/c', 'x/y');
//=> false

isPathInside('a/b/c', 'a/b/c');
//=> false

isPathInside('/Users/sindresorhus/dev/unicorn', '/Users/sindresorhus');
//=> true

API

isPathInside(childPath, parentPath)

Note that relative paths are resolved against process.cwd() to make them absolute.

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.

childPath

Type: string

The path that should be inside parentPath.

parentPath

Type: string

The path that should contain childPath.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
版本列表
4.0.0 2021-05-03
3.0.3 2021-03-08
3.0.2 2019-09-30
3.0.1 2019-07-05
3.0.0 2019-07-05
2.1.0 2019-04-15
2.0.0 2018-03-22
1.0.1 2017-11-30
1.0.0 2014-08-14
0.1.0 2014-06-20