You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

is-subdir

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-subdir

Return whether a directory is a subdirectory of another directory

1.2.0
latest
Source
npmnpm
Version published
Weekly downloads
1.4M
-20.38%
Maintainers
1
Weekly downloads
 
Created

What is is-subdir?

The is-subdir npm package is a utility that helps determine if a given directory is a subdirectory of another directory. This can be useful in various scenarios such as validating file paths, ensuring security by restricting access to certain directories, and more.

What are is-subdir's main functionalities?

Check if a directory is a subdirectory

This feature allows you to check if a given directory is a subdirectory of another directory. In this example, '/home/user/projects/my-app' is a subdirectory of '/home/user/projects', so the function returns true.

const isSubdir = require('is-subdir');
const parentDir = '/home/user/projects';
const subDir = '/home/user/projects/my-app';
console.log(isSubdir(parentDir, subDir)); // true

Check if a directory is not a subdirectory

This feature allows you to check if a given directory is not a subdirectory of another directory. In this example, '/home/user/other-projects' is not a subdirectory of '/home/user/projects', so the function returns false.

const isSubdir = require('is-subdir');
const parentDir = '/home/user/projects';
const notSubDir = '/home/user/other-projects';
console.log(isSubdir(parentDir, notSubDir)); // false

Other packages similar to is-subdir

Keywords

subdirectory

FAQs

Package last updated on 05 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.