summaryrefslogtreecommitdiff
path: root/vendor/github.com/authzed/spicedb/internal/datastore/common/url.go
blob: be665ed20ab2eccc88092021c726ecc5216f8e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package common

import (
	"errors"
	"net/url"
)

// MetricsIDFromURL extracts the metrics ID from a given datastore URL.
func MetricsIDFromURL(dsURL string) (string, error) {
	if dsURL == "" {
		return "", errors.New("datastore URL is empty")
	}

	u, err := url.Parse(dsURL)
	if err != nil {
		return "", errors.New("could not parse datastore URL")
	}
	return u.Host + u.Path, nil
}