github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/pkg/api/apiutil/endpoint.go (about)

     1  package apiutil
     2  
     3  import (
     4  	"net/url"
     5  	"strings"
     6  )
     7  
     8  // NormalizeLakeFSEndpoint verify and return the endpoint for the lakeFS server
     9  func NormalizeLakeFSEndpoint(endpoint string) (string, error) {
    10  	u, err := url.Parse(endpoint)
    11  	if err != nil {
    12  		return "", err
    13  	}
    14  	// if no uri to api is set in configuration - set the default
    15  	if u.Path == "" || u.Path == "/" {
    16  		endpoint = strings.TrimRight(endpoint, "/") + BaseURL
    17  	}
    18  	return endpoint, nil
    19  }