Skip to content

Commit

Permalink
fix(agent): add a config upgrade action to remove trailing slash from…
Browse files Browse the repository at this point in the history
… host
  • Loading branch information
joshuar committed Jul 3, 2023
1 parent c1a1511 commit 1be71ad
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"net/url"
"reflect"
"strings"
"time"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -135,8 +136,9 @@ func (c *agentConfig) Upgrade() error {
if err != nil {
return err
}
switch {
// * Upgrade host to include scheme for versions < v.1.4.0
if semver.Compare(configVersion.(string), "v1.4.0") < 0 {
case semver.Compare(configVersion.(string), "v1.4.0") < 0:
host, err := c.Get("host")
if err != nil {
return err
Expand All @@ -157,6 +159,16 @@ func (c *agentConfig) Upgrade() error {
newHost = "http://" + host.(string)
}
c.Set("Host", newHost)
fallthrough
// * Trim trailing slash from host for versions < v1.4.3
case semver.Compare(configVersion.(string), "v1.4.3") < 0:
host, err := c.Get("host")
if err != nil {
return err
}
var newHost string
newHost = strings.TrimSuffix(host.(string), "/")
c.Set("Host", newHost)
}

c.Set("Version", Version)
Expand Down

0 comments on commit 1be71ad

Please sign in to comment.