sindresorhus/prepend-http

Prepend `https://` to humanized URLs like `sindresorhus.com` and `localhost`

JavaScript

66

35 commits

updated Sep 18, 2026

See the code

README

prepend-http

Prepend https:// to humanized URLs like sindresorhus.com and localhost

Install

npm install prepend-http

Usage

import prependHttp from 'prepend-http';

prependHttp('sindresorhus.com');
//=> 'https://sindresorhus.com'

prependHttp('localhost', {https: false});
//=> 'http://localhost'

prependHttp('https://sindresorhus.com');
//=> 'https://sindresorhus.com'

API

prependHttp(url, options?)

url

Type: string

The URL to prepend https:// to.

options

Type: object

https

Type: boolean
Default: true

Prepend https:// instead of http://.

Notes

URLs with authentication information (e.g., login:password@site.com) are returned unchanged as basic auth in URLs is deprecated and to avoid conflicting with custom schemes.

sindresorhus/prepend-http

Prepend `https://` to humanized URLs like `sindresorhus.com` and `localhost`

JavaScript

66

35 commits

updated Sep 18, 2026

See the code

README

prepend-http

Prepend https:// to humanized URLs like sindresorhus.com and localhost

Install

npm install prepend-http

Usage

import prependHttp from 'prepend-http';

prependHttp('sindresorhus.com');
//=> 'https://sindresorhus.com'

prependHttp('localhost', {https: false});
//=> 'http://localhost'

prependHttp('https://sindresorhus.com');
//=> 'https://sindresorhus.com'

API

prependHttp(url, options?)

url

Type: string

The URL to prepend https:// to.

options

Type: object

https

Type: boolean
Default: true

Prepend https:// instead of http://.

Notes

URLs with authentication information (e.g., login:password@site.com) are returned unchanged as basic auth in URLs is deprecated and to avoid conflicting with custom schemes.

Project health

Overall

3.5/10

Maintained

0/10

Code review

1/10
OpenSSF Scorecard

Latest release

4.0.0 · Aug 9, 2021

Releases this year

0