• Version 4.0.0
  • Published
  • 4.2 kB
  • No dependencies
  • MIT license


npm i is-path-inside
yarn add is-path-inside
pnpm add is-path-inside


Check if a path is inside another path



function isPathInside

isPathInside: (childPath: string, parentPath: string) => boolean;
  • Check if a path is inside another path.

    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.

    Example 1

    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

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (3)

Peer Dependencies (0)

No peer dependencies.


To add a badge like this badgeto your package's README, use the codes available below.

You may also use to create a custom badge linking to

  • Markdown
  • HTML
    <a href=""><img src="" alt=""></a>