Skip to content

Commit

Permalink
Allow for incorrect and missing schemes.
Browse files Browse the repository at this point in the history
Fixes hashrocket#12

Also picked up a few unrelated gofmt changes.

Signed-off-by: Brian Brazil <[email protected]>
  • Loading branch information
brian-brazil committed Dec 22, 2019
1 parent bc51635 commit 51992ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func connect(url, origin string, rlConf *readline.Config, allowInsecure bool) er

dialer := websocket.Dialer{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig:&tls.Config{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: allowInsecure,
},
}
Expand Down
18 changes: 17 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Version = "0.2.1"
var options struct {
origin string
printVersion bool
insecure bool
insecure bool
}

func main() {
Expand Down Expand Up @@ -50,6 +50,22 @@ func root(cmd *cobra.Command, args []string) {
os.Exit(1)
}

// Correct and add missing schemes.
switch dest.Scheme {
case "ws", "wss":
case "http":
dest.Scheme = "ws"
case "https":
dest.Scheme = "wss"
default:
// Likely no scheme at all, e.g. "localhost:8000".
dest, err = url.Parse("ws://" + args[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}

var origin string
if options.origin != "" {
origin = options.origin
Expand Down
6 changes: 3 additions & 3 deletions vendor/github.com/mattn/go-colorable/colorable_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51992ac

Please sign in to comment.