Skip to content

Commit

Permalink
Merge pull request #11 from CookPete/master
Browse files Browse the repository at this point in the history
Return the correct host for git@ URLs
  • Loading branch information
jonschlinkert authored Nov 1, 2017
2 parents 2afab62 + 12a5fe4 commit ec38e82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ec38e82

Please sign in to comment.