Parcourir la source

trim slashes from the right while setting host in the CLI

Mohammed Nafees il y a 4 ans
Parent
commit
b4ec6fc2d7
1 fichiers modifiés avec 4 ajouts et 0 suppressions
  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()