# protocolify

> Prepend `https://` to humanized URLs like `sindresorhus.com` and `file://` to file paths

Latest version **4.0.0** (published 2021-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install protocolify
pnpm add protocolify
yarn add protocolify
bun add protocolify
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2021-08-09 |
| First published | 2014-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 2 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | protocol, scheme, url, uri, prepend, http, file, path |

## Links

- npm: https://www.npmjs.com/package/protocolify
- Repository: https://github.com/sindresorhus/protocolify
- Homepage: https://github.com/sindresorhus/protocolify#readme
- Issues: https://github.com/sindresorhus/protocolify/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/protocolify

## Dependencies (2)

- [file-url](https://npm.io/package/file-url.md) ^4.0.0
- [prepend-http](https://npm.io/package/prepend-http.md) ^4.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2021-08-09
- 3.0.0 — 2019-05-01
- 2.0.0 — 2017-01-13
- 1.0.3 — 2016-05-16
- 1.0.2 — 2015-10-05
- 1.0.1 — 2015-05-02
- 1.0.0 — 2014-11-16

## README

# protocolify

> Prepend `https://` to humanized URLs like `sindresorhus.com` and `file://` to file paths

Useful when you want to accept either a local file or URL as argument in your CLI app.

## Install

```
$ npm install protocolify
```

## Usage

```js
import protocolify from 'protocolify';

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

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

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

// If it exists on disk, it will be interpreted as a file and not a URL
protocolify('index.js');
//=> 'file:///Users/sindresorhus/dev/protocolify/index.js'
```

## API

### protocolify(urlOrFilePath, options?)

#### urlOrFilePath

Type: `string`

The URL to prepend `https://` or file path to prepend `file://`.

#### options

Type: `object`

##### https

Type: `boolean`\
Default: `true`

Prepend `https://` instead of `http://` to URLs.

---
_Source: https://npm.io/package/protocolify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
