diff --git a/gitinfo/gitinfo.go b/gitinfo/gitinfo.go index 93c4af99c5f8a6deb212f0c5e42885427624112d..57147d5026b37573f7e1765b3a718d39408cf158 100644 --- a/gitinfo/gitinfo.go +++ b/gitinfo/gitinfo.go @@ -3,9 +3,11 @@ package gitinfo import ( "context" "errors" + "fmt" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/murphysecurity/murphysec/infra/logctx" + "net/url" "time" ) @@ -74,7 +76,16 @@ func getRemoteURL(ctx context.Context, repo *git.Repository) (string, error) { return "", _ErrNoRemoteURLFound } - return candidateURLs[0], nil + var candidateURL = candidateURLs[0] + + u, err := url.Parse(candidateURL) + if err != nil { + return candidateURL, nil + } + + var newURL = fmt.Sprintf("%s://%s%s", u.Scheme, u.Host, u.Path) + + return newURL, nil } func getCommitInfo(ctx context.Context, repo *git.Repository, hash plumbing.Hash) (*commitInfo, error) {