Skip to content

Commit

Permalink
fix: http protocol use sshurl by default
Browse files Browse the repository at this point in the history
PR-URL: #48
Credit: @fengmk2
Close: #48
Reviewed-by: @isaacs
  • Loading branch information
fengmk2 authored and isaacs committed Aug 5, 2019
1 parent 2d5aa25 commit 3b1d629
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ GitHost.prototype.getDefaultRepresentation = function () {
}

GitHost.prototype.toString = function (opts) {
const method = this.default || /* istanbul ignore next */ 'sshurl'
return this[method](opts)
if (this.default && typeof this[this.default] === 'function') return this[this.default](opts)
return this.sshurl(opts)
}
2 changes: 2 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ test('basic', function (t) {
t.is(HostedGit.fromUrl('git+file:///foo/bar'), undefined, 'url that has no host')
t.is(HostedGit.fromUrl('github.com/abc/def/'), undefined, 'forgot the protocol')
t.is(HostedGit.fromUrl('completely-invalid'), undefined, 'not a url is not hosted')

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')
t.end()
})

0 comments on commit 3b1d629

Please sign in to comment.