Skip to content

Commit a158d7a

Browse files
authored
check host exist (#58)
1 parent 54690b4 commit a158d7a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/scm-clients/clients/clients.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package clients
22

33
import (
4+
"errors"
45
"fmt"
56
"strings"
67

@@ -69,14 +70,17 @@ func FetchClientData(accessToken string, repoUrl string) (*checkmodels.AssetsDat
6970

7071
func getRepoInfo(repoUrl string) (scm string, org string, repo string, err error) {
7172
u, err := url.Parse(repoUrl)
72-
if err != nil {
73+
if err != nil || u.Scheme == "" {
7374
logger.Errorf(err, "error in parsing repoUrl %s", repoUrl)
75+
if err == nil {
76+
err = errors.New("error in parsing the host")
77+
}
7478
return "", "", "", err
7579
}
7680

7781
path := strings.Split(u.EscapedPath(), "/")
7882
if len(path) < 3 {
79-
return "", "", "", fmt.Errorf("missing org and repo in the repository url: %s", repoUrl)
83+
return "", "", "", fmt.Errorf("missing org/repo in the repository url: %s", repoUrl)
8084
}
8185
return u.Host, path[1], path[2], nil
8286
}

0 commit comments

Comments
 (0)