Skip to content

Commit 12a5fe4

Browse files
committed
Return the correct host for git@ URLs
Fixes jonschlinkert#10
1 parent 2afab62 commit 12a5fe4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

index.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ function parse(str) {
2929
return null;
3030
}
3131

32+
if (!obj.host && /^git@/.test(str) === true) {
33+
// return the correct host for git@ URLs
34+
obj.host = url.parse('http://' + str).host;
35+
}
36+
3237
obj.path = trimSlash(obj.path);
3338
obj.pathname = trimSlash(obj.pathname);
3439
obj.filepath = null;

test.js

+4
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ describe('parse-github-url', function() {
204204
assert.equal(gh('https://github.com/assemble/verb').host, 'github.com');
205205
assert.equal(gh('https://github.one.com/assemble/verb').host, 'github.one.com');
206206
assert.equal(gh('https://github.one.two.com/assemble/verb').host, 'github.one.two.com');
207+
assert.equal(gh('git@gh.pages.com:assemble/verb.git').host, 'gh.pages.com');
208+
assert.equal(gh('git@gh.pages.com:assemble/dot.repo.git').host, 'gh.pages.com');
209+
assert.equal(gh('git@bitbucket.org:atlassian/atlaskit.git').host, 'bitbucket.org');
210+
assert.equal(gh('git@gitlab.com:gitlab-org/gitlab-ce.git').host, 'gitlab.com');
207211
});
208212

209213
it('should assume github.com is the host when not provided:', function() {

0 commit comments

Comments
 (0)