Skip to content

Commit

Permalink
Fix startup if scheme is missing in server URL
Browse files Browse the repository at this point in the history
If the scheme in the server URL is missing 'http' is added as default
scheme and the url is parsed again. With this behaviour the user does
not need to enter the scheme if it would be 'http'.
  • Loading branch information
seternate committed May 21, 2024
1 parent 7f0de68 commit 7e0d60c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ func NewController(ctx context.Context) *Controller {
if err != nil {
log.Fatal().Err(err).Send()
}
url, err := url.Parse(settings.ServerURL)

u, err := url.Parse(settings.ServerURL)
if len(u.Host) == 0 {
u, err = url.Parse("http://" + settings.ServerURL)
}
if err != nil {
log.Fatal().Err(err).Str("url", settings.ServerURL).Msg("failed to parse server URL")
}
client := api.NewClient(url, timeout)

client := api.NewClient(u, timeout)
if err != nil {
log.Fatal().Err(err).Msg("failed to create API client")
}
Expand Down

0 comments on commit 7e0d60c

Please sign in to comment.