Skip to content

Commit

Permalink
Fixes issues where trailing slash in CF endpoint causes problems (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwmac authored and Irfan Habib committed Aug 17, 2017
1 parent eda7922 commit e4050b9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions components/app-core/backend/cnsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"

log "github.com/Sirupsen/logrus"
"github.com/labstack/echo"
Expand Down Expand Up @@ -63,6 +64,9 @@ func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, sk
"CNSI Name or Endpoint were not provided when trying to register an CF Cluster")
}

apiEndpoint = strings.TrimRight(apiEndpoint, "/")

// Remove trailing slash, if there is one
apiEndpointURL, err := url.Parse(apiEndpoint)
if err != nil {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
Expand Down Expand Up @@ -252,6 +256,9 @@ func (p *portalProxy) GetCNSIRecord(guid string) (interfaces.CNSIRecord, error)
return interfaces.CNSIRecord{}, err
}

// Ensure that trailing slash is removed from the API Endpoint
rec.APIEndpoint.Path = strings.TrimRight(rec.APIEndpoint.Path, "/")

return rec, nil
}

Expand Down

0 comments on commit e4050b9

Please sign in to comment.