Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

login: detect missing protocol in URL#54

Merged
Russtopia merged 1 commit intomasterfrom53-detect-missing-protocol
Jun 19, 2020

Conversation

Russtopia
Copy link

@RusstopiaRusstopia commentedJun 19, 2020
edited
Loading

Fixes#53

What This Does

Detects a user entering a URL without the protocol field, eg. 'localhost:8080' instead of 'http://localhost:8080' which would result in a malformed login URL, and the stored state using incorrect API paths for all coder-cli operations (eg. sync, sh) which give obscure rsync errors.

Since the cli library dispatches sub-commands to the login.Run() function as non-writable array fl.Arg(), the URL can't be patched up silently to be correct, so instead this patch detects the missing protocol prefix in the URL, and prints out a help usage modified to explain that http[s]:// is required.

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 againsthttp://localhost:8080,http://master.cdr.dev/ andhttps://master.cdr.dev/ and all seem to work (ie., master.cdr.dev auto-downgrades the login URL to http, which I assume is desired).

@ammarioammario removed their request for reviewJune 19, 2020 21:05
Copy link
Contributor

@cmoogcmoog left a comment

Choose a reason for hiding this comment

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

LGTM

@RusstopiaRusstopia merged commitc69c791 intomasterJun 19, 2020
@RusstopiaRusstopia deleted the 53-detect-missing-protocol branchJune 19, 2020 23:49
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@cmoogcmoogcmoog approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

login: Malformed login URL arg breaks login, sh and sync
2 participants
@Russtopia@cmoog

[8]ページ先頭

©2009-2025 Movatter.jp