New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

is-subdir

Package Overview
Dependencies
Maintainers
1
Versions
7
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

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
2.9M
-3.45%
Maintainers
1
Weekly downloads
 
Created
Source

is-subdir

Return whether a directory is a subdirectory of another directory

npm version

Cross-platform. Works correctly on Windows, where directory paths can start with disk drive letters in different casings. Like c:\foo and C:\foo\bar.

Returns true when the directories match. The isSubdir.strict() variant only returns true if the second parameter is a strict subdir of the first and not the same.

Installation

<npm|yarn|pnpm> add is-subdir

Usage

'use strict'
const path = require('path')
const isSubdir = require('is-subdir')

console.log(isSubdir(process.cwd(), path.resolve('node_modules')))
//> true
console.log(isSubdir.strict('node_modules/tape', '../tape'))
//> false

API

isSubdir(parentDir, subdir): boolean

isSubdir.strict(parentDir, subdir): boolean

License

MIT © Zoltan Kochan

Keywords

subdirectory

FAQs

Package last updated on 11 Mar 2026

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