From 9067893000a88f7082bfb562d18e0eae38310e27 Mon Sep 17 00:00:00 2001 From: Andrew Calder Date: Mon, 20 Oct 2025 10:45:20 +0100 Subject: [PATCH] fix: .Hostname() may strip port, use .Host Calling u.Hostname() strips port number, resulting in default port i.e. 443 being used. The u.Host member provides host and (if specified) port. --- internal/glrepo/repo.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/glrepo/repo.go b/internal/glrepo/repo.go index e4279c7aa..36aec78d3 100644 --- a/internal/glrepo/repo.go +++ b/internal/glrepo/repo.go @@ -175,7 +175,7 @@ func FromURL(u *url.URL, defaultHostname string) (Interface, error) { cfg, err := config.ParseDefaultConfig() // an error is fine here, there might not be a config available if err == nil { - apiHost, _ = cfg.Get(u.Hostname(), "api_host") + apiHost, _ = cfg.Get(u.Host, "api_host") } if apiHost != "" { @@ -200,11 +200,11 @@ func FromURL(u *url.URL, defaultHostname string) (Interface, error) { if repo != "" && pathWithoutRepo != "" { parts := strings.SplitN(pathWithoutRepo, "/", 2) if len(parts) == 1 { - return NewWithHost(parts[0], repo, u.Hostname()), nil + return NewWithHost(parts[0], repo, u.Host), nil } if len(parts) == 2 { - return NewWithGroup(parts[0], parts[1], repo, u.Hostname(), defaultHostname), nil + return NewWithGroup(parts[0], parts[1], repo, u.Host, defaultHostname), nil } } return nil, fmt.Errorf("invalid path: %s", u.Path) -- GitLab