diff --git a/index.js b/index.js index a167729..a6e514d 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,11 @@ function parse(str) { return null; } + if (!obj.host && /^git@/.test(str) === true) { + // return the correct host for git@ URLs + obj.host = url.parse('http://' + str).host; + } + obj.path = trimSlash(obj.path); obj.pathname = trimSlash(obj.pathname); obj.filepath = null; diff --git a/test.js b/test.js index c8d566f..1015721 100644 --- a/test.js +++ b/test.js @@ -204,6 +204,10 @@ describe('parse-github-url', function() { assert.equal(gh('https://github.com/assemble/verb').host, 'github.com'); assert.equal(gh('https://github.one.com/assemble/verb').host, 'github.one.com'); assert.equal(gh('https://github.one.two.com/assemble/verb').host, 'github.one.two.com'); + assert.equal(gh('git@gh.pages.com:assemble/verb.git').host, 'gh.pages.com'); + assert.equal(gh('git@gh.pages.com:assemble/dot.repo.git').host, 'gh.pages.com'); + assert.equal(gh('git@bitbucket.org:atlassian/atlaskit.git').host, 'bitbucket.org'); + assert.equal(gh('git@gitlab.com:gitlab-org/gitlab-ce.git').host, 'gitlab.com'); }); it('should assume github.com is the host when not provided:', function() {