mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 00:26:36 +03:00
lib/netutil/netutil: fix strings index check
### Describe Your Changes
Properly check precense of `/`, previously it was
ignoring a case where "/" would be at the beginning of the string.
This is a follow-up for 00712b18
---------
Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
This commit is contained in:
@@ -80,7 +80,7 @@ func IsErrMissingPort(err error) bool {
|
||||
// It returns the normalized address in the form "host:port".
|
||||
// It is expected that addr is in the form "host" or "host:port".
|
||||
func NormalizeAddr(addr string, defaultPort int) (string, error) {
|
||||
if strings.Index(addr, "/") > 0 {
|
||||
if strings.Contains(addr, "/") {
|
||||
return "", fmt.Errorf("invalid address %q; expected format: host:port", addr)
|
||||
}
|
||||
|
||||
|
||||
@@ -65,4 +65,5 @@ func TestNormalizeAddrError(t *testing.T) {
|
||||
f("http://127.0.0.1:80")
|
||||
f("http://vmstorage-0.svc.cluster.local.")
|
||||
f("http://vmstorage-0.svc.cluster.local.:80")
|
||||
f("/vmstorage-0.svc.cluster.local.:80")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user