Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-11.63%
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

FAQs

Package last updated on 01 Mar 2019

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc