Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

protocolify

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protocolify

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

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30K
decreased by-27.53%
Maintainers
1
Weekly downloads
 
Created
Source

protocolify Build Status

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

const protocolify = require('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

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.

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 01 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc