prepend-http is a focused utility package designed to ensure URLs have a proper `http://` or `https://` protocol prefix. It intelligently adds `https://` (by default) to "humanized" URLs such as domain names (`sindresorhus.com`) or `localhost` entries, while leaving already-prefixed URLs untouched. The package is currently stable at version `4.0.0`, released recently in response to ecosystem changes. Historically, releases are infrequent but significant, often tied to Node.js LTS updates or module system shifts. A key differentiator is its simplicity and reliability, provided by a well-regarded maintainer in the JavaScript ecosystem. Since version 4, prepend-http is a pure ESM package, aligning with modern JavaScript module practices, and requires Node.js 12.20 or newer.
npm install prepend-httpVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `prependHttp` with various URL inputs, including defaulting to `https`, explicitly using `http`, and handling already-prefixed URLs.
Update all imports to use ESM `import` syntax (e.g., `import prependHttp from 'prepend-http';`). Ensure your Node.js project is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` file extensions).
Upgrade your Node.js runtime to version 12.20.0, 14.13.1, or any version 16.0.0 or newer.
If you require `http://` by default, explicitly pass `{ https: false }` as the second argument: `prependHttp(url, { https: false })`.Upgrade your Node.js runtime to version 8 or higher. (Note: v4.0.0 requires an even newer Node.js version, see other warnings).
Change `const prependHttp = require('prepend-http');` to `import prependHttp from 'prepend-http';`. Ensure your environment supports ESM (e.g., `"type": "module"` in `package.json`).Ensure you are using `import prependHttp from 'prepend-http';` in an ESM context. If you must `require` from a CJS file, consider using dynamic `import()`: `const { default: prependHttp } = await import('prepend-http');` (requires `async/await`).Replace `const prependHttp = require('prepend-http');` with `import prependHttp from 'prepend-http';` and ensure all other dependencies are imported using `import` statements.No dependency data recorded yet.