Skip to content

Commit

Permalink
[v2] Validate devServer property to be of the correct form (#1359)
Browse files Browse the repository at this point in the history
  • Loading branch information
stffabi authored Apr 28, 2022
1 parent 0a9ae0d commit d912018
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions v2/cmd/wails/internal/commands/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"net"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -125,6 +126,16 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
return err
}

devServer := flags.devServer
if _, _, err := net.SplitHostPort(devServer); err != nil {
return fmt.Errorf("DevServer is not of the form 'host:port', please check your wails.json")
}

devServerURL, err := url.Parse("http://" + devServer)
if err != nil {
return err
}

// Update go.mod to use current wails version
err = syncGoModVersion(cwd)
if err != nil {
Expand Down Expand Up @@ -175,11 +186,6 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
defer closer(&devCommandWaitGroup)
}

devServerURL, err := url.Parse("http://" + flags.devServer)
if err != nil {
return err
}

// open browser
if flags.openBrowser {
err = browser.OpenURL(devServerURL.String())
Expand Down

0 comments on commit d912018

Please sign in to comment.