diff --git a/internal/normalize/normailze.go b/internal/normalize/normailze.go index d6ed45d..6bd7203 100644 --- a/internal/normalize/normailze.go +++ b/internal/normalize/normailze.go @@ -11,6 +11,9 @@ import ( // GitRemote helper // Returns normalized git remote - valid even on error func GitRemote(sugar *zap.SugaredLogger, gitRemote string) string { + if len(gitRemote) == 0 { + return "" + } gitRemote = strings.TrimSuffix(gitRemote, ".git") parsedURL, err := giturls.Parse(gitRemote) if err != nil { diff --git a/internal/normalize/normalize_test.go b/internal/normalize/normalize_test.go index 847928d..a85b538 100644 --- a/internal/normalize/normalize_test.go +++ b/internal/normalize/normalize_test.go @@ -37,10 +37,15 @@ func TestGitRemote(t *testing.T) { one := normalize.GitRemote(sugar, arr[i]) two := normalize.GitRemote(sugar, arr[j]) if one != two { - t.Fatalf("Normalized git remotes should match for '%s' and '%s'\n -> got: '%s' != '%s'", + t.Fatalf("Normalized git remotes should match for '%s' and '%s'\n -> got '%s' != '%s'", arr[i], arr[j], one, two) } } } } + + empty := normalize.GitRemote(sugar, "") + if len(empty) != 0 { + t.Fatalf("Normalized git remotes for '' should be ''\n -> got '%s'", empty) + } } diff --git a/internal/searchapp/item.go b/internal/searchapp/item.go index 2cd9ef2..3c86cd5 100644 --- a/internal/searchapp/item.go +++ b/internal/searchapp/item.go @@ -402,7 +402,7 @@ func NewItemFromRecordForQuery(record recordint.SearchApp, query Query, debug bo // -> N matches against the command // -> 1 extra match for the actual directory match sameGitRepo := false - if query.gitOriginRemote != "" && query.gitOriginRemote == record.GitOriginRemote { + if len(query.gitOriginRemote) != 0 && query.gitOriginRemote == record.GitOriginRemote { sameGitRepo = true }