
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
is-relative-path
Advanced tools
The is-relative-path npm package is a simple utility that helps determine if a given path is a relative path. This can be useful in various scenarios where path validation or manipulation is required.
Check if a path is relative
This feature allows you to check if a given path is relative. It returns true if the path is relative and false if it is absolute.
const isRelativePath = require('is-relative-path');
console.log(isRelativePath('./some/path')); // true
console.log(isRelativePath('/absolute/path')); // false
The is-absolute package is the counterpart to is-relative-path, focusing on determining if a path is absolute. While it serves a different primary purpose, it can be used in conjunction with is-relative-path for comprehensive path validation.
The path module is a core Node.js module that provides utilities for working with file and directory paths. It includes methods for checking if paths are absolute or relative, among other functionalities. It is more comprehensive but also more complex than is-relative-path.
Sometimes I just want to scream
npm install is-relative-path
isRelative(path)
path
<string>
<boolean>
var isRelative = require('is-relative-path');
isRelative('../'); // true
isRelative('/'); // false
Version | Code |
---|---|
1.x | (path) => path[0] === '.' |
2.x | (path) => !path.isAbsolute(path) |
path | v1.x | v2.x |
---|---|---|
"" | false | true |
"." | true | true |
".." | true | true |
"foo" | false | true |
"/foo" | false | false |
FAQs
Whether or not a given path is relative
The npm package is-relative-path receives a total of 558,468 weekly downloads. As such, is-relative-path popularity was classified as popular.
We found that is-relative-path 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.