Skip to content

Commit

Permalink
Revert "Fix URL in no token error message (#1166)" (#1173)
Browse files Browse the repository at this point in the history
This reverts commit 102aeb8.
  • Loading branch information
IsaacG authored Sep 18, 2024
1 parent c3738a8 commit 62d9851
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
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

0 comments on commit 62d9851

Please sign in to comment.