Skip to content

Commit 3b1d629

Browse files
fengmk2isaacs
authored andcommitted
fix: http protocol use sshurl by default
PR-URL: #48 Credit: @fengmk2 Close: #48 Reviewed-by: @isaacs
1 parent 2d5aa25 commit 3b1d629

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

git-host.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,6 @@ GitHost.prototype.getDefaultRepresentation = function () {
151151
}
152152

153153
GitHost.prototype.toString = function (opts) {
154-
const method = this.default || /* istanbul ignore next */ 'sshurl'
155-
return this[method](opts)
154+
if (this.default && typeof this[this.default] === 'function') return this[this.default](opts)
155+
return this.sshurl(opts)
156156
}

test/basic.js

+2
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ test('basic', function (t) {
3535
t.is(HostedGit.fromUrl('git+file:///foo/bar'), undefined, 'url that has no host')
3636
t.is(HostedGit.fromUrl('github.com/abc/def/'), undefined, 'forgot the protocol')
3737
t.is(HostedGit.fromUrl('completely-invalid'), undefined, 'not a url is not hosted')
38+
39+
t.is(HostedGit.fromUrl('http://github.com/foo/bar').toString(), 'git+ssh://git@github.com/foo/bar.git', 'github http protocol use git+ssh urls')
3840
t.end()
3941
})

0 commit comments

Comments
 (0)