Skip to content

Commit

Permalink
remove any trailing slash from baseUrl
Browse files Browse the repository at this point in the history
- also rename url var to something more informative
  • Loading branch information
aaperis committed Mar 7, 2024
1 parent cf96780 commit 20a36a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type AuthInfo struct {

// requests the /info endpoint to fetch the parameters needed for login
func GetAuthInfo(baseURL string) (*AuthInfo, error) {
url := baseURL + "/info"
url := strings.TrimSuffix(baseURL, "/") + "/info"
resp, err := http.Get(url)
if err != nil {
return nil, err
Expand Down Expand Up @@ -181,15 +181,15 @@ func NewLogin(args []string) error {
// `clientID` set.
func NewDeviceLogin(args []string) (DeviceLogin, error) {

var url string
var loginUrl string
err := Args.Parse(args[1:])
if err != nil {
return DeviceLogin{}, err
}
if len(Args.Args()) == 1 {
url = Args.Args()[0]
loginUrl = Args.Args()[0]
}
info, err := GetAuthInfo(url)
info, err := GetAuthInfo(loginUrl)
if err != nil {
return DeviceLogin{}, fmt.Errorf("failed parsing arguments: %v", err)
}
Expand Down

0 comments on commit 20a36a3

Please sign in to comment.