From 64799d7b890bab986e5cae5880e4096026c2b58a Mon Sep 17 00:00:00 2001 From: Preslav Gerchev Date: Fri, 29 Sep 2023 11:58:34 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Do=20not=20try=20and=20parse=20g?= =?UTF-8?q?ithub=20repo=20if=20owner=20is=20set.=20(#1978)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/github/provider/provider.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/providers/github/provider/provider.go b/providers/github/provider/provider.go index 74efd2259d..83d85c6d7b 100644 --- a/providers/github/provider/provider.go +++ b/providers/github/provider/provider.go @@ -175,11 +175,15 @@ func (s *Service) detect(asset *inventory.Asset, conn *connection.GithubConnecti asset.Id = conn.Conf.Type asset.Name = conn.Conf.Host - if x, ok := conn.Conf.Options["repository"]; ok { - fullRepo := x - repoParts := strings.Split(fullRepo, "/") - conn.Conf.Options["owner"] = repoParts[0] - conn.Conf.Options["repository"] = repoParts[1] + repoOpt := conn.Conf.Options["repository"] + ownerOpt := conn.Conf.Options["owner"] + // try and parse the repo only if the owner isnt explicitly set + if repoOpt != "" && ownerOpt == "" { + repoParts := strings.Split(repoOpt, "/") + if len(repoParts) > 1 { + conn.Conf.Options["owner"] = repoParts[0] + conn.Conf.Options["repository"] = repoParts[1] + } } platform, err := conn.PlatformInfo()