aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'git-codereview/config.go')
-rw-r--r--git-codereview/config.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/git-codereview/config.go b/git-codereview/config.go
index debeb5e..cc9286c 100644
--- a/git-codereview/config.go
+++ b/git-codereview/config.go
@@ -6,6 +6,7 @@ package main
import (
"fmt"
+ "net/url"
"os"
"path/filepath"
"strings"
@@ -59,20 +60,18 @@ func haveGerritInternal(gerrit, origin string) bool {
if gerrit != "" {
return true
}
- if strings.Contains(origin, "github.com") {
+
+ u, err := url.Parse(origin)
+ if err != nil {
return false
}
- if strings.HasPrefix(origin, "sso://") || strings.HasPrefix(origin, "rpc://") {
+ if u.Scheme == "sso" || u.Scheme == "rpc" {
return true
}
- if !strings.Contains(origin, "https://") {
- return false
- }
- if strings.Count(origin, "/") != 3 {
+ if u.Scheme != "https" {
return false
}
- host := origin[:strings.LastIndex(origin, "/")]
- return strings.HasSuffix(host, ".googlesource.com")
+ return strings.HasSuffix(u.Host, ".googlesource.com")
}
func haveGitHub() bool {