Comparing version 0.0.2 to 0.0.3
@@ -21,3 +21,3 @@ #! /usr/bin/env node | ||
.usage('Usage: gitio <command>') | ||
.command('shrink', 'Shrink a GitHub url', shrink) | ||
.command('shrink', 'Shrink a GitHub URL.', shrink) | ||
.demand(1) | ||
@@ -24,0 +24,0 @@ .alias('v', 'version') |
@@ -64,3 +64,5 @@ /** | ||
/** | ||
* Parses the URL so that it is in compliance with Git.io's backend. | ||
* Parses the URL so that it is in compliance with Git.io's backend. This | ||
* functions ensures that the URLs always starts wth `http://`, as the git.io | ||
* will not accept URLs that start with `//`, `http://`, or neither. | ||
* | ||
@@ -71,9 +73,15 @@ * @param {string} url | ||
function parseUrl(url) { | ||
// Handle "//github.com". | ||
if (url.indexOf('//') === 0) { | ||
return 'https:' + url; | ||
} else if (url.indexOf('http') !== 0) { | ||
} | ||
// Handle "http://github.com" or "github.com". | ||
if (url.indexOf('http://') === 0) { | ||
return url.replace('http://', 'https://'); | ||
} else { | ||
return 'https://' + url; | ||
} else { | ||
return url.replace('http://', 'https://'); | ||
} | ||
return url; | ||
} |
{ | ||
"name": "node-gitio", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A simple Node CLI wrapper for git.io.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,9 +0,11 @@ | ||
# node-gitio | ||
# node-gitio [](https://travis-ci.org/nathanbuchar/node-gitio) | ||
A simple Node CLI wrapper for [git.io](https://github.com/blog/985-git-io-github-url-shortener). In Terminal, simply enter `gitio shrink` followed by the GitHub URL you would like to shrink and the shortened URL will be copied automatically to your clipboard. | ||
A simple Node CLI wrapper for [http://git.io](http://git.io/). In Terminal, simply enter `gitio shrink` followed by the GitHub URL you would like to shrink and the shortened URL will be copied automatically to your clipboard. Read more about git.io [here](https://github.com/blog/985-git-io-github-url-shortener). | ||
Copying to clipboard is implemented via the [copy-paste](https://www.npmjs.com/package/copy-paste) package which supports OSX, Windows, Linux, and OpenBSD. | ||
**A quick note:** This is not a generic URL shortener. git.io—and by extension, this package—only shortens links that are hosted within the `github.com` domain. | ||
### Install | ||
@@ -16,11 +18,25 @@ | ||
### Quick Visual Guide | ||
```bash | ||
$ gitio shrink github.com/.../my_cool_package | ||
# => http://git.io/vZHUg (copied to clipboard) | ||
$ gitio shrink github.com/.../my_cool_package -c mycoolpackage | ||
# => http://git.io/mycoolpackage (copied to clipboard) | ||
``` | ||
### Usage | ||
``` | ||
Usage: gitio <command> | ||
Usage: gitio <command> [options] | ||
Commands: | ||
shrink Shrink a GitHub url | ||
shrink Shrink a GitHub URL. | ||
@@ -41,8 +57,8 @@ Options: | ||
--code, -c A custom code for the short link, e.g. http://git.io/mycode. (Optional) | ||
--code, -c A custom code for the short link, e.g. http://git.io/mycode. (Optional) | ||
--force, -f Try to shorten link even if the custom code has been used previously. | ||
(Optional) | ||
--force, -f Try to shorten link even if the custom code has been used previously. | ||
(Optional) | ||
--help, -h Show the help menu. | ||
--help, -h Show the help menu. | ||
@@ -49,0 +65,0 @@ ``` |
9289
158
135