node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

to-protocol-relative-url

to-protocol-relative-url.js

NPM version Bower version Build Status Build status Coverage Status Dependency Status devDependency Status

Change a URL into protocol-relative URL

Installation

Package managers

npm

npm install --save to-protocol-relative-url

Bower

bower install --save to-protocol-relative-url

Standalone

Download the script file directly.

API

toProtocolRelativeUrl(url)

url: String
Return: String

toProtocolRelativeURL('http://example.org');
//=> //example.org 
 
toProtocolRelativeURL('https://github.com/');
//=> //github.com/ 
 
toProtocolRelativeURL('git@github.com:npm/npm.git');
//=> git@github.com:npm/npm.git (doesn't change) 
 
toProtocolRelativeURL('Here is http://nodejs.org');
//=> Here is http://nodejs.org (doesn't change) 

CLI

You can use this module as a CLI tool by installing it globally.

npm install -g to-protocol-relative-url

Usage

Usage1: to-protocol-relative-url <string>
Usage2: echo <string> | to-protocol-relative-url
 
Options:
--help,    -h  Print usage information
--version, -v  Print version

License

Copyright (c) 2014 - 2015 Shinnosuke Watanabe

Licensed under the MIT License.