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

Signed-off-by: Brian Brazil <[email protected]>
  • Loading branch information
brian-brazil committed Dec 22, 2019
1 parent bc51635 commit 660f45f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
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

0 comments on commit 660f45f

Please sign in to comment.