Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

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