diff --git a/lib/getRepoInfo.js b/lib/getRepoInfo.js index 609d3cf..e92fd17 100644 --- a/lib/getRepoInfo.js +++ b/lib/getRepoInfo.js @@ -1,6 +1,9 @@ const url = require('url') module.exports = repositoryUrl => { + if (repositoryUrl.startsWith('git@')) { + repositoryUrl = 'ssh://' + repositoryUrl + } const parsedUrl = new url.URL( // without these replacements we will get a TypeError [ERR_INVALID_URL] repositoryUrl.replace('.com:', '.com/').replace('.org:', '.org/') diff --git a/test/test_getRepoInfo.js b/test/test_getRepoInfo.js index f5a4461..641b767 100644 --- a/test/test_getRepoInfo.js +++ b/test/test_getRepoInfo.js @@ -36,4 +36,11 @@ describe('test getRepoInfo', () => { const expectedUrl = 'https://github.com/hello/world' runAssert(repositoryUrl, expectedPath, expectedUrl) }) + + it('should work for repo url with git@', () => { + const repositoryUrl = 'git@github.com:hello/world.git' + const expectedPath = 'hello/world' + const expectedUrl = 'https://github.com/hello/world' + runAssert(repositoryUrl, expectedPath, expectedUrl) + }) })