InferSiteURL guesses what the website URL is. The basis for the guess is which API we're submitting to.
(apiURL string)
| 118 | // InferSiteURL guesses what the website URL is. |
| 119 | // The basis for the guess is which API we're submitting to. |
| 120 | func InferSiteURL(apiURL string) string { |
| 121 | if apiURL == "" { |
| 122 | apiURL = defaultBaseURL |
| 123 | } |
| 124 | if apiURL == "https://api.exercism.org/v1" { |
| 125 | return "https://exercism.org" |
| 126 | } |
| 127 | re := regexp.MustCompile("^(https?://[^/]*).*") |
| 128 | return re.ReplaceAllString(apiURL, "$1") |
| 129 | } |
| 130 | |
| 131 | // TokenURL provides a link to where the user can find their API token. |
| 132 | func TokenURL(apiURL string) string { |
no outgoing calls