Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
path-is-absolute
Advanced tools
The path-is-absolute npm package provides a simple utility to check if a given path is an absolute path. In different operating systems, an absolute path is defined differently, and this package takes those differences into account, offering a consistent API across environments.
Check if a path is absolute
This feature allows you to check if a given path string represents an absolute path on the current operating system. The function returns a boolean value: true if the path is absolute, and false otherwise.
var pathIsAbsolute = require('path-is-absolute');
console.log(pathIsAbsolute('/home/foo')); // On Unix: true
console.log(pathIsAbsolute('C:\\path\\to\\file')); // On Windows: true
console.log(pathIsAbsolute('foo/bar')); // false
Similar to path-is-absolute, is-absolute checks if a given path is absolute. It provides a more comprehensive API with additional checks and utilities around path analysis compared to path-is-absolute.
While is-relative serves the opposite purpose of path-is-absolute, it is relevant in the context of path analysis. It checks if a path is relative, which can be useful in conjunction with path-is-absolute for applications that need to validate paths extensively.
This package is no longer relevant as Node.js 0.12 is unmaintained.
Node.js 0.12
path.isAbsolute()
ponyfill
$ npm install --save path-is-absolute
const pathIsAbsolute = require('path-is-absolute');
// Running on Linux
pathIsAbsolute('/home/foo');
//=> true
pathIsAbsolute('C:/Users/foo');
//=> false
// Running on Windows
pathIsAbsolute('C:/Users/foo');
//=> true
pathIsAbsolute('/home/foo');
//=> false
// Running on any OS
pathIsAbsolute.posix('/home/foo');
//=> true
pathIsAbsolute.posix('C:/Users/foo');
//=> false
pathIsAbsolute.win32('C:/Users/foo');
//=> true
pathIsAbsolute.win32('/home/foo');
//=> false
See the path.isAbsolute()
docs.
POSIX specific version.
Windows specific version.
MIT © Sindre Sorhus
FAQs
Node.js 0.12 path.isAbsolute() ponyfill
The npm package path-is-absolute receives a total of 37,425,488 weekly downloads. As such, path-is-absolute popularity was classified as popular.
We found that path-is-absolute demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.