is-path-inside

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

Install

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

Overview

Check if a path is inside another path

Index

Functions

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.

Badge

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

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/is-path-inside.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/is-path-inside)
  • HTML
    <a href="https://www.jsdocs.io/package/is-path-inside"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>