From 0bdc8550aa5d14b57c462e5cd8ade69e07812c8e Mon Sep 17 00:00:00 2001 From: Dries De Peuter Date: Wed, 10 Jan 2024 08:45:41 +0100 Subject: [PATCH] fix: No replace on http/s protocol --- internal/pkg/command/clone.go | 4 ++++ internal/pkg/command/clone_test.go | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/internal/pkg/command/clone.go b/internal/pkg/command/clone.go index 41fbdec..400ad85 100644 --- a/internal/pkg/command/clone.go +++ b/internal/pkg/command/clone.go @@ -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()) { diff --git a/internal/pkg/command/clone_test.go b/internal/pkg/command/clone_test.go index 758c4b3..8738261 100644 --- a/internal/pkg/command/clone_test.go +++ b/internal/pkg/command/clone_test.go @@ -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 {