Strip trailing separator in URL in config host add (#2680)
Also, in the case of find command for existing configs that has a trailing separator in the URL, trim the separator from the URL. Fixes #2645
This commit is contained in:
@@ -227,7 +227,7 @@ func mainConfigHostAdd(ctx *cli.Context) error {
|
||||
console.SetColor("HostMessage", color.New(color.FgGreen))
|
||||
var (
|
||||
args = ctx.Args()
|
||||
url = args.Get(1)
|
||||
url = trimTrailingSeparator(args.Get(1))
|
||||
accessKey = args.Get(2)
|
||||
secretKey = args.Get(3)
|
||||
api = ctx.String("api")
|
||||
|
||||
@@ -41,6 +41,12 @@ func isValidSecretKey(secretKey string) bool {
|
||||
return len(secretKey) >= secretKeyMinLen
|
||||
}
|
||||
|
||||
// trimTrailingSeparator - Remove trailing separator.
|
||||
func trimTrailingSeparator(hostURL string) string {
|
||||
separator := string(newClientURL(hostURL).Separator)
|
||||
return strings.TrimSuffix(hostURL, separator)
|
||||
}
|
||||
|
||||
// isValidHostURL - validate input host url.
|
||||
func isValidHostURL(hostURL string) (ok bool) {
|
||||
if strings.TrimSpace(hostURL) != "" {
|
||||
|
||||
+1
-1
@@ -209,7 +209,7 @@ func getAliasedPath(ctx *findContext, path string) string {
|
||||
prefixPath := ctx.clnt.GetURL().String()
|
||||
var aliasedPath string
|
||||
if ctx.targetAlias != "" {
|
||||
aliasedPath = ctx.targetAlias + strings.TrimPrefix(path, ctx.targetFullURL)
|
||||
aliasedPath = ctx.targetAlias + strings.TrimPrefix(path, strings.TrimSuffix(ctx.targetFullURL, separator))
|
||||
} else {
|
||||
aliasedPath = path
|
||||
// look for prefix path, if found filter at that, Watch calls
|
||||
|
||||
Reference in New Issue
Block a user