Procházet zdrojové kódy

trim slashes from the right while setting host in the CLI

Mohammed Nafees před 4 roky
rodič
revize
b4ec6fc2d7
1 změnil soubory, kde provedl 4 přidání a 0 odebrání
  1. 4 0
      cli/cmd/config.go

+ 4 - 0
cli/cmd/config.go

@@ -6,6 +6,7 @@ import (
 	"os"
 	"path/filepath"
 	"strconv"
+	"strings"
 
 	"github.com/fatih/color"
 	"github.com/spf13/cobra"
@@ -179,6 +180,9 @@ func (c *CLIConfig) SetDriver(driver string) error {
 }
 
 func (c *CLIConfig) SetHost(host string) error {
+	// a trailing / can lead to errors with the api server
+	host = strings.TrimRight(host, "/")
+
 	viper.Set("host", host)
 	color.New(color.FgGreen).Printf("Set the current host as %s\n", host)
 	err := viper.WriteConfig()