Fix CLI URL scheme handling when using http:// addresses

The browse command and config loading were incorrectly prepending https:// to hosts that already had a scheme, resulting in malformed URLs like https://http://localhost:8080. Added normalizeHost() function to strip URL schemes when loading config, and added scheme detection in the browse command before prepending https://.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-18 17:19:44 +01:00
parent d92632933b
commit 0f1fc2f069
2 changed files with 30 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ import (
"fmt"
"os/exec"
"runtime"
"strings"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cmd/cmdutil"
@@ -57,11 +58,15 @@ func NewCmdBrowse(f *cmdutil.Factory) *cobra.Command {
flagOrg = hc.Organization
}
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") {
host = "https://" + host
}
var url string
if flagOrg != "" {
url = fmt.Sprintf("https://%s/organizations/%s", host, flagOrg)
url = fmt.Sprintf("%s/organizations/%s", host, flagOrg)
} else {
url = fmt.Sprintf("https://%s", host)
url = host
}
if flagNoBrowser || f.IOStreams.ForceNonInteractive {