Socket
Socket
Sign inDemoInstall

protocolify

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 3.0.0

index.d.ts

8

index.js

@@ -6,8 +6,8 @@ 'use strict';

module.exports = function (url) {
if (typeof url !== 'string') {
throw new TypeError(`Expected a string, got ${typeof url}`);
module.exports = (urlOrFilePath, options) => {
if (typeof urlOrFilePath !== 'string') {
throw new TypeError(`Expected a \`string\`, got \`${typeof urlOrFilePath}\``);
}
return fs.existsSync(url) ? fileUrl(url) : prependHttp(url);
return fs.existsSync(urlOrFilePath) ? fileUrl(urlOrFilePath) : prependHttp(urlOrFilePath, options);
};
{
"name": "protocolify",
"version": "2.0.0",
"description": "Prepend `http://` to humanized URLs like `todomvc.com` and `file://` to file paths",
"license": "MIT",
"repository": "sindresorhus/protocolify",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"protocol",
"scheme",
"url",
"uri",
"prepend",
"http",
"file",
"path"
],
"dependencies": {
"file-url": "^2.0.0",
"prepend-http": "^1.0.4"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "protocolify",
"version": "3.0.0",
"description": "Prepend `https://` to humanized URLs like `sindresorhus.com` and `file://` to file paths",
"license": "MIT",
"repository": "sindresorhus/protocolify",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"protocol",
"scheme",
"url",
"uri",
"prepend",
"http",
"file",
"path"
],
"dependencies": {
"file-url": "^3.0.0",
"prepend-http": "^3.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}
# protocolify [![Build Status](https://travis-ci.org/sindresorhus/protocolify.svg?branch=master)](https://travis-ci.org/sindresorhus/protocolify)
> Prepend `http://` to humanized URLs like `todomvc.com` and `file://` to file paths
> Prepend `https://` to humanized URLs like `sindresorhus.com` and `file://` to file paths

@@ -11,3 +11,3 @@ Useful when you want to accept either a local file or URL as argument in your CLI app.

```
$ npm install --save protocolify
$ npm install protocolify
```

@@ -21,12 +21,12 @@

protocolify('todomvc.com');
//=> 'http://todomvc.com'
protocolify('sindresorhus.com');
//=> 'https://sindresorhus.com'
protocolify('localhost');
protocolify('localhost', {https: false});
//=> 'http://localhost'
protocolify('http://todomvc.com');
//=> 'http://todomvc.com'
protocolify('https://sindresorhus.com');
//=> 'https://sindresorhus.com'
// if it exists on disk it will be interpreted as a file and not an URL
// If it exists on disk, it will be interpreted as a file and not a URL
protocolify('index.js');

@@ -37,4 +37,26 @@ //=> '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`<br>
Default: `true`
Prepend `https://` instead of `http://` to URLs.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc