From 177ca32b9b77f7206bd244b4f8921b865c4a6d04 Mon Sep 17 00:00:00 2001 From: TimZhang Date: Fri, 11 Apr 2014 18:04:01 +0800 Subject: [PATCH] Fix title problem when repo url doesn't have .git suffix --- bin/utils.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/utils.js b/bin/utils.js index 3aa4f1838..4d45e293f 100644 --- a/bin/utils.js +++ b/bin/utils.js @@ -32,15 +32,18 @@ function gitURL(path) { // Poorman's parsing // Parse a git URL to a github ID : username/reponame function githubID(_url) { + // Remove .git if it's in _url + var sliceEnd = _url.slice(-4) === '.git' ? -4 : _url.length; + // Detect HTTPS repos var parsed = url.parse(_url); if(parsed.protocol === 'https:' && parsed.host === 'github.com') { - return parsed.path.slice(1, -4); + return parsed.path.slice(1, sliceEnd); } // Detect SSH repos if(_url.indexOf('git@') === 0) { - return _url.split(':', 2)[1].slice(0, -4); + return _url.split(':', 2)[1].slice(0, sliceEnd); } // None found