Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

login: detect missing protocol in URL #54

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/coder/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net"
"net/http"
"net/url"
"strings"
"sync"

"github.com/pkg/browser"
Expand All @@ -22,13 +23,13 @@ type loginCmd struct {
func (cmd loginCmd) Spec() cli.CommandSpec {
return cli.CommandSpec{
Name: "login",
Usage: "[Coder Enterprise URL]",
Usage: "[Coder Enterprise URL eg. http://my.coder.domain/ ]",
Desc: "authenticate this client for future operations",
}
}
func (cmd loginCmd) Run(fl *pflag.FlagSet) {
rawURL := fl.Arg(0)
if rawURL == "" {
if rawURL == "" || !strings.HasPrefix(rawURL, "http") {
exitUsage(fl)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested against http://localhost:8080, http://master.cdr.dev/ and https://master.cdr.dev/ and all seem to work (ie., master.cdr.dev auto-downgrades the login URL to http, which I assume is desired).

}

Expand Down