Skip to content

Commit 0c6d097

Browse files
author
Stephen Gutekanst
committed
unify endpoint trailing slash handling
1 parent 6fcdf8f commit 0c6d097

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

cmd/src/api.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ Examples:
120120
// gqlURL returns the URL to the GraphQL endpoint for the given Sourcegraph
121121
// instance.
122122
func gqlURL(endpoint string) string {
123-
if !strings.HasSuffix(endpoint, "/") {
124-
endpoint = endpoint + "/"
125-
}
126-
return endpoint + ".api/graphql"
123+
return endpoint + "/.api/graphql"
127124
}
128125

129126
// curlCmd returns the curl command to perform the given GraphQL query. Bash-only.

cmd/src/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"os/user"
1111
"path/filepath"
12+
"strings"
1213
)
1314

1415
const usageText = `src is a tool that provides access to Sourcegraph instances.
@@ -85,7 +86,7 @@ func readConfig() (*config, error) {
8586
cfg.AccessToken = envToken
8687
}
8788
if *endpoint != "" {
88-
cfg.Endpoint = *endpoint
89+
cfg.Endpoint = strings.TrimSuffix(*endpoint, "/")
8990
}
9091
if cfg.Endpoint == "" {
9192
cfg.Endpoint = "https://sourcegraph.com"

0 commit comments

Comments
 (0)