diff --git a/cli/azd/pkg/pipeline/github_provider.go b/cli/azd/pkg/pipeline/github_provider.go index 842c91bda85..60886f31a16 100644 --- a/cli/azd/pkg/pipeline/github_provider.go +++ b/cli/azd/pkg/pipeline/github_provider.go @@ -132,10 +132,10 @@ func (p *GitHubScmProvider) configureGitRemote( } // defines the structure of an ssl git remote -var gitHubRemoteGitUrlRegex = regexp.MustCompile(`^git@github\.com:(.*?)(?:\.git)?$`) +var gitHubRemoteGitUrlRegex = regexp.MustCompile(`^git@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}:(.*?)(?:\.git)?$`) // defines the structure of an HTTPS git remote -var gitHubRemoteHttpsUrlRegex = regexp.MustCompile(`^https://(?:www\.)?github\.com/(.*?)(?:\.git)?$`) +var gitHubRemoteHttpsUrlRegex = regexp.MustCompile(`^https://(?:www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/(.*?)(?:\.git)?$`) // ErrRemoteHostIsNotGitHub the error used when a non GitHub remote is found var ErrRemoteHostIsNotGitHub = errors.New("not a github host") diff --git a/cli/azd/pkg/pipeline/github_provider_test.go b/cli/azd/pkg/pipeline/github_provider_test.go index 3eb37c02f59..88d7b2ad8ab 100644 --- a/cli/azd/pkg/pipeline/github_provider_test.go +++ b/cli/azd/pkg/pipeline/github_provider_test.go @@ -40,7 +40,7 @@ func Test_gitHub_provider_getRepoDetails(t *testing.T) { t.Run("error", func(t *testing.T) { provider := &GitHubScmProvider{} ctx := context.Background() - details, e := provider.gitRepoDetails(ctx, "git@other.com:Azure/azure-dev.git") + details, e := provider.gitRepoDetails(ctx, "gt@other.com:Azure/azure-dev.git") require.Error(t, e, ErrRemoteHostIsNotGitHub) require.EqualValues(t, (*gitRepositoryDetails)(nil), details) })