2.0.3 • Published 7 years ago
is-path-from-ancestor v2.0.3
is-path-from-ancestor
A Node.js module to check if a given path starts with parent directory reference
const isPathFromAncestor = require('is-path-from-ancestor');
// On POSIX
isPathFromAncestor('../foo'); //=> true
isPathFromAncestor('foo'); //=> false
// On Windows
isPathFromAncestor('..\\foo'); //=> trueInstallation
npm install is-path-from-ancestorAPI
const isPathFromAncestor = require('is-path-from-ancestor');isPathFromAncestor(path)
path: string
Return: boolean
It returns true if path starts with ../ (POSIX) or ..\\ (Windows), otherwise returns false.
It normalizes the path before checking.
// On POSIX
isPathFromAncestor('foo/../../'); //=> true
isPathFromAncestor('foo/../'); //=> false