Merge pull request #10 from dpogue/github-url

Support git shortlink package references
diff --git a/index.js b/index.js
index d17d6c3..9d77f04 100644
--- a/index.js
+++ b/index.js
@@ -25,6 +25,7 @@
 var fs = require('fs');
 var CordovaError = require('cordova-common').CordovaError;
 var isUrl = require('is-url');
+var hostedGitInfo = require('hosted-git-info');
 
 /*
  * A function that npm installs a module from npm or a git url
@@ -147,7 +148,10 @@
 function trimID (target) {
     var parts;
     // If GITURL, set target to repo name
-    if (isUrl(target)) {
+    var gitInfo = hostedGitInfo.fromUrl(target);
+    if (gitInfo) {
+        target = gitInfo.project;
+    } else if (isUrl(target)) {
         // strip away .git and everything that follows
         var strippedTarget = target.split('.git');
         var re = /.*\/(.*)/;
diff --git a/package.json b/package.json
index f808596..54c0697 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
   "dependencies": {
     "cordova-common": "2.1.1",
     "dependency-ls": "^1.1.0",
+    "hosted-git-info": "^2.5.0",
     "is-url": "^1.2.1",
     "q": "^1.4.1",
     "shelljs": "^0.7.0"
diff --git a/spec/fetch.spec.js b/spec/fetch.spec.js
index bb8424a..4d9369c 100644
--- a/spec/fetch.spec.js
+++ b/spec/fetch.spec.js
@@ -241,8 +241,8 @@
                 expect(fs.existsSync(result)).toBe(true);
                 expect(result).toMatch('cordova-plugin-device');
 
-                // refetch to trigger trimID
-                return fetch('https://github.com/apache/cordova-plugin-media.git', tmpDir, opts);
+                // refetch to trigger trimID, with shortcode URL
+                return fetch('github:apache/cordova-plugin-media', tmpDir, opts);
             })
             .then(function (result) {
                 expect(result).toBeDefined();