Skip to content

Commit

Permalink
fix(getrepoinfo): fix for other TLD checking in repo url (#33)
Browse files Browse the repository at this point in the history
Now plugin should work properly with private/internal repositories with other TLD than .com
  • Loading branch information
voltane authored and juliuscc committed Jan 16, 2020
1 parent 07b918d commit 22d83db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/getRepoInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ module.exports = repositoryUrl => {
}
const parsedUrl = new url.URL(
// without these replacements we will get a TypeError [ERR_INVALID_URL]
repositoryUrl.replace('.com:', '.com/').replace('.org:', '.org/')
repositoryUrl.replace(
/\.([a-z])*:/i,
rep => rep.substring(0, rep.length - 1) + '/'
)
)
const path = parsedUrl.pathname
.substring(1) // remove leading "/"
Expand Down
7 changes: 7 additions & 0 deletions test/test_getRepoInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ describe('test getRepoInfo', () => {
const expectedUrl = 'https://github.com/hello/world'
runAssert(repositoryUrl, expectedPath, expectedUrl)
})

it('should work for repo url with other TLD', () => {
const repositoryUrl = 'git@github.pl:hello/world.git'
const expectedPath = 'hello/world'
const expectedUrl = 'https://github.pl/hello/world'
runAssert(repositoryUrl, expectedPath, expectedUrl)
})
})

0 comments on commit 22d83db

Please sign in to comment.