Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/utils/git-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export function normalizeGitUrl(input: string): string | null {
const url = input
.trim()
.replace(/^git\+/, '')
.replace(/\.git$/, '')
.replace(/\.git(?=[/#?]|$)/i, '')
.replace(/(^|\/)[^/]+?@/, '$1') // remove "user@" from "ssh://user@host.com:..."
.replace(/(\.[^./]+?):/, '$1/') // change ".com:" to ".com/" from "ssh://user@host.com:..."
.replace(/^git:\/\//, 'https://')
Expand Down
6 changes: 6 additions & 0 deletions test/unit/shared/utils/git-providers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ describe('normalizeGitUrl', () => {
expect
.soft(normalizeGitUrl('https://bitbucket.org/user/repo.git'))
.toBe('https://bitbucket.org/user/repo')
expect
.soft(normalizeGitUrl('git+https://github.com/user/repo.git#readme'))
.toBe('https://github.com/user/repo#readme')
expect
.soft(normalizeGitUrl('git+https://github.com/user/repo.git?path=packages/core'))
.toBe('https://github.com/user/repo?path=packages/core')
})

it('should convert git:// protocol to https://', () => {
Expand Down
Loading