diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-26 09:12:00 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-26 09:12:00 +0100 |
commit | 75b217fc246be108368ed0e3c3adda3dc85fd615 (patch) | |
tree | b0482e14970e6bdb95c9bbffb3fedab326c713a1 /lib/utils | |
parent | d6b44cc149fd6889f77107bb365a68079811576f (diff) | |
download | gitbook-75b217fc246be108368ed0e3c3adda3dc85fd615.zip gitbook-75b217fc246be108368ed0e3c3adda3dc85fd615.tar.gz gitbook-75b217fc246be108368ed0e3c3adda3dc85fd615.tar.bz2 |
Support ssh urls in git parsing
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/git.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/utils/git.js b/lib/utils/git.js index c37f326..f7f63e7 100644 --- a/lib/utils/git.js +++ b/lib/utils/git.js @@ -25,14 +25,19 @@ function validateSha(str) { // Parse and extract infos function parseGitUrl(giturl) { + var ref, parts; + if (!checkGitUrl(giturl)) return null; giturl = giturl.slice(GIT_PREFIX.length); - var parts = url.parse(giturl); + if (!url.parse(giturl).protocol) { + giturl = "ssh://"+giturl; + } + var normalized = ngu(giturl); - console.log(normalized); - var ref = parts.hash; + parts = url.parse(normalized.url); + ref = normalized.branch; // Extract file inside the repo (after the .git) var fileParts = parts.pathname.split(".git"); |