2.0.3 • Published 5 years ago

is-path-from-ancestor v2.0.3

Weekly downloads
1
License
CC0-1.0
Repository
github
Last release
5 years ago

is-path-from-ancestor

npm version Build Status Coverage Status

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'); //=> true

Installation

Use npm.

npm install is-path-from-ancestor

API

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

License

Creative Commons Zero v1.0 Universal

2.0.3

5 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.0.0

10 years ago