Skip to content

Commit

Permalink
fix: No replace on http/s protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Jan 10, 2024
1 parent a822866 commit 0bdc855
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/pkg/command/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func cloneRepo(repo string) (string, error) {
}

func makeURL(u *url.URL, renameRepo map[string]string) (string, error) {
if u.Scheme == "http" || u.Scheme == "https" {
return u.String(), nil
}

for host, match := range renameRepo {
r := regexp.MustCompile(regexp.QuoteMeta(match))
if r.MatchString(u.String()) {
Expand Down
9 changes: 9 additions & 0 deletions internal/pkg/command/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ func Test_makeURL(t *testing.T) {
want: "ssh://git@gh-personal/bla/bla",
wantErr: false,
},
{
name: "no-replace-in-http",
renameMap: map[string]string{
"github.com/bla": "gh-personal",
},
URL: "http://github.com/bla/bla",
want: "http://github.com/bla/bla",
wantErr: false,
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 0bdc855

Please sign in to comment.