diff --git a/internal/pkg/create/create.go b/internal/pkg/create/create.go index 0c0a38a2..ec10801b 100644 --- a/internal/pkg/create/create.go +++ b/internal/pkg/create/create.go @@ -524,7 +524,7 @@ func InstallProjectDependencies( // generateGitZipFileURL will return the GitHub zip URL for a templateURL. func generateGitZipFileURL(httpClient slackhttp.HTTPClient, templateURL string, gitBranch string) string { - zipURL := strings.ReplaceAll(templateURL, ".git", "") + "/archive/refs/heads/" + zipURL := strings.TrimSuffix(templateURL, ".git") + "/archive/refs/heads/" if gitBranch == "" { mainURL := zipURL + "main.zip" diff --git a/internal/pkg/create/create_test.go b/internal/pkg/create/create_test.go index df8082f3..ac67e39c 100644 --- a/internal/pkg/create/create_test.go +++ b/internal/pkg/create/create_test.go @@ -128,6 +128,24 @@ func Test_generateGitZipFileURL(t *testing.T) { httpClientMock.On("Get", mock.Anything).Return(nil, fmt.Errorf("HTTPClient error")) }, }, + "Returns the zip URL with .git suffix removed": { + templateURL: "https://github.com/slack-samples/deno-starter-template.git", + gitBranch: "", + expectedURL: "https://github.com/slack-samples/deno-starter-template/archive/refs/heads/main.zip", + setupHTTPClientMock: func(httpClientMock *slackhttp.HTTPClientMock) { + res := slackhttp.MockHTTPResponse(http.StatusOK, "OK") + httpClientMock.On("Get", mock.Anything).Return(res, nil) + }, + }, + "Returns the zip URL with .git inside URL preserved": { + templateURL: "https://github.com/slack-samples/deno.git-starter-template", + gitBranch: "", + expectedURL: "https://github.com/slack-samples/deno.git-starter-template/archive/refs/heads/main.zip", + setupHTTPClientMock: func(httpClientMock *slackhttp.HTTPClientMock) { + res := slackhttp.MockHTTPResponse(http.StatusOK, "OK") + httpClientMock.On("Get", mock.Anything).Return(res, nil) + }, + }, } for name, tt := range tests { t.Run(name, func(t *testing.T) {