Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix URL in no token error message (#1166)" #1173

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cmd/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestDownloadWithoutToken(t *testing.T) {
if assert.Error(t, err) {
assert.Regexp(t, "Welcome to Exercism", err.Error())
// It uses the default base API url to infer the host
assert.Regexp(t, "exercism.org/settings/api_cli", err.Error())
assert.Regexp(t, "exercism.io/my/settings", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestSubmitWithoutToken(t *testing.T) {
err := runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), []string{})
if assert.Error(t, err) {
assert.Regexp(t, "Welcome to Exercism", err.Error())
assert.Regexp(t, "exercism.org/settings/api_cli", err.Error())
assert.Regexp(t, "exercism.io/my/settings", err.Error())
}
}

Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var (
defaultBaseURL = "https://exercism.org"
defaultBaseURL = "https://api.exercism.io/v1"

// DefaultDirName is the default name used for config and workspace directories.
DefaultDirName string
Expand Down Expand Up @@ -122,13 +122,13 @@ func InferSiteURL(apiURL string) string {
apiURL = defaultBaseURL
}
if apiURL == "https://api.exercism.io/v1" {
return "https://exercism.org"
return "https://exercism.io"
}
re := regexp.MustCompile("^(https?://[^/]*).*")
return re.ReplaceAllString(apiURL, "$1")
}

// SettingsURL provides a link to where the user can find their API token.
func SettingsURL(apiURL string) string {
return fmt.Sprintf("%s%s", InferSiteURL(apiURL), "/settings/api_cli")
return fmt.Sprintf("%s%s", InferSiteURL(apiURL), "/my/settings")
}
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ func TestInferSiteURL(t *testing.T) {
testCases := []struct {
api, url string
}{
{"https://api.exercism.io/v1", "https://exercism.org"},
{"https://api.exercism.io/v1", "https://exercism.io"},
{"https://v2.exercism.io/api/v1", "https://v2.exercism.io"},
{"https://mentors-beta.exercism.io/api/v1", "https://mentors-beta.exercism.io"},
{"http://localhost:3000/api/v1", "http://localhost:3000"},
{"", "https://exercism.org"}, // use the default
{"", "https://exercism.io"}, // use the default
{"http://whatever", "http://whatever"}, // you're on your own, pal
}

Expand Down
Loading