Просмотр исходного кода

trim slashes from the right while setting host in the CLI

Mohammed Nafees 4 лет назад
Родитель
Сommit
b4ec6fc2d7
1 измененных файлов с 4 добавлено и 0 удалено
  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()