This package provides a focused utility function to determine if a given string adheres to the structural requirements of an HTTP or HTTPS URL. Currently at version 1.0.3, it is a stable, low-cadence library, primarily maintained for compatibility and reliability rather than frequent feature additions. Its core validation logic is built upon a robust regular expression initially developed by Diego Perini, which is well-regarded for its comprehensive coverage of various URL components. Unlike larger, more feature-rich URL parsing libraries, `is-valid-http-url` offers a lightweight and direct API specifically for string format validation, making it ideal for scenarios where only a quick check for valid HTTP/HTTPS URL syntax is needed without additional overhead.
npm install is-valid-http-urlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and use the `isUrl` function to validate various HTTP and HTTPS URL strings, showcasing both valid and invalid examples.
If you require validation beyond format (e.g., checking if a URL is alive), you will need to integrate additional network request logic (e.g., using `fetch` or `axios`).
For validating non-HTTP/HTTPS URLs, use a more general URL parsing library or a validator specific to that protocol.
For critical applications with highly varied URL inputs, consider combining this with broader URL parsing libraries like Node.js's built-in `URL` class or `url-parse` for deeper structural analysis if needed.
Change the import statement to `import isUrl from 'is-valid-http-url';` for ESM environments.
Ensure you are using `const isUrl = require('is-valid-http-url');` in CommonJS, or `import isUrl from 'is-valid-http-url';` in ESM, as the package provides a default function export.No dependency data recorded yet.