Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues where trailing slash in CF endpoint causes problems #1224

Merged
merged 1 commit into from
Aug 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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