Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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 32,510,576 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.