Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
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.
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 19,018,378 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.