Skip to content

Commit 3a8f2a6

Browse files
authored
Merge pull request caprover#1553 from jonaskuske/patch-3
fix: allow dot in repo name
2 parents 706f44d + 053cc46 commit 3a8f2a6

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/utils/GitHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class GitHelper {
1818
/(?<domain>[^\s\/\?#:]+)/,
1919
/(?::(?<port>[0-9]{1,5}))?/,
2020
/(?:[\/:](?<owner>[^\s\/\?#:]+))?/,
21-
/(?:[\/:](?<repo>[^\s\/\?#:.]+))/,
21+
/(?:[\/:](?<repo>(?:[^\s\/\?#:.]|\.(?!git\/?\s*$))+))/,
2222
/(?:.git)?\/?\s*$/,
2323
]
2424
.map((r) => r.source)

tests/GitHelper.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,40 @@ test('Testing - sanitizeRepoPathSsh from HTTPS', () => {
4848
).toBe('ssh://git@github.com:22/username/repository.git')
4949
})
5050

51+
test('Testing - sanitizeRepoPathSsh - name with dot', () => {
52+
expect(
53+
GitHelper.sanitizeRepoPathSsh(' github.com/owner/site.com ').repoPath
54+
).toBe('ssh://git@github.com:22/owner/site.com.git')
55+
})
56+
57+
test('Testing - sanitizeRepoPathSsh - name with dot and git suffix', () => {
58+
expect(
59+
GitHelper.sanitizeRepoPathSsh(' github.com/owner/site.com.git ')
60+
.repoPath
61+
).toBe('ssh://git@github.com:22/owner/site.com.git')
62+
})
63+
64+
test('Testing - sanitizeRepoPathSsh - name containing ".git"', () => {
65+
expect(
66+
GitHelper.sanitizeRepoPathSsh(' github.com/owner/repo.github ')
67+
.repoPath
68+
).toBe('ssh://git@github.com:22/owner/repo.github.git')
69+
})
70+
71+
test('Testing - sanitizeRepoPathSsh - name containing ".git" and git suffix', () => {
72+
expect(
73+
GitHelper.sanitizeRepoPathSsh(' github.com/owner/repo.github.git ')
74+
.repoPath
75+
).toBe('ssh://git@github.com:22/owner/repo.github.git')
76+
})
77+
78+
test('Testing - sanitizeRepoPathSsh - name containing ".git", git suffix and /', () => {
79+
expect(
80+
GitHelper.sanitizeRepoPathSsh(' github.com/owner/repo.github.git/ ')
81+
.repoPath
82+
).toBe('ssh://git@github.com:22/owner/repo.github.git')
83+
})
84+
5185
test('Testing - sanitizeRepoPathSsh - not git suffix', () => {
5286
expect(
5387
GitHelper.sanitizeRepoPathSsh(' github.com/owner/repository ').repoPath

0 commit comments

Comments
 (0)