Skip to content
Change a URL into protocol-relative URL
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
appveyor.yml
bower.json
cli.js
package.json
test.js
to-protocol-relative-url-cjs.js
to-protocol-relative-url.js

README.md

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.

Something went wrong with that request. Please try again.