Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
is-relative-url
Advanced tools
The is-relative-url npm package is a simple utility that checks if a given URL is a relative URL. It is useful for validating and processing URLs in web development.
Check if a URL is relative
This feature allows you to check if a given URL is relative. A relative URL does not include the domain name and is relative to the current page's URL.
const isRelativeUrl = require('is-relative-url');
console.log(isRelativeUrl('/path/to/resource')); // true
console.log(isRelativeUrl('http://example.com')); // false
The is-absolute-url package checks if a given URL is an absolute URL. It complements is-relative-url by providing the opposite functionality, allowing developers to validate absolute URLs.
The url-parse package is a more comprehensive URL parsing library that can handle both relative and absolute URLs. It provides more advanced features such as extracting components of the URL, making it more versatile compared to is-relative-url.
The valid-url package provides functions to validate URLs, including checking if they are valid, absolute, or relative. It offers a broader range of validation options compared to is-relative-url.
Check if a URL is relative
npm install is-relative-url
import isRelativeUrl from 'is-relative-url';
isRelativeUrl('foo/bar');
//=> true
isRelativeUrl('https://sindresorhus.com/foo/bar');
//=> false
isRelativeUrl('//sindresorhus.com');
//=> true
See is-absolute-url for the inverse.
FAQs
Check if a URL is relative
The npm package is-relative-url receives a total of 243,180 weekly downloads. As such, is-relative-url popularity was classified as popular.
We found that is-relative-url 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.