{"library":"prepend-http","title":"Prepend HTTP/S Protocol to URLs","description":"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.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install prepend-http"],"cli":null},"imports":["import prependHttp from 'prepend-http';","import type { Options } from 'prepend-http';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import prependHttp from 'prepend-http';\n\n// Example 1: Basic usage - prepends https:// by default\nconst url1 = 'sindresorhus.com';\nconst prefixedUrl1 = prependHttp(url1);\nconsole.log(`'${url1}' -> '${prefixedUrl1}'`);\n// Expected: 'sindresorhus.com' -> 'https://sindresorhus.com'\n\n// Example 2: Explicitly prepend http://\nconst url2 = 'localhost:3000';\nconst prefixedUrl2 = prependHttp(url2, { https: false });\nconsole.log(`'${url2}' -> '${prefixedUrl2}'`);\n// Expected: 'localhost:3000' -> 'http://localhost:3000'\n\n// Example 3: URL already has a protocol - should be untouched\nconst url3 = 'ftp://example.com/file.txt';\nconst prefixedUrl3 = prependHttp(url3);\nconsole.log(`'${url3}' -> '${prefixedUrl3}'`);\n// Expected: 'ftp://example.com/file.txt' -> 'ftp://example.com/file.txt'\n\n// Example 4: Mixed case - ensure consistency\nconst url4 = 'http://github.com';\nconst prefixedUrl4 = prependHttp(url4);\nconsole.log(`'${url4}' -> '${prefixedUrl4}'`);\n// Expected: 'http://github.com' -> 'http://github.com'","lang":"typescript","description":"Demonstrates how to use `prependHttp` with various URL inputs, including defaulting to `https`, explicitly using `http`, and handling already-prefixed URLs.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}