Skip to content

Commit c3ba801

Browse files
author
Tomas Kubovic
committed
Added trim [] for IPv6 address in getDeviceByIP method
1 parent edea6f0 commit c3ba801

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

client/getDevice.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"crypto/x509"
2222
"errors"
2323
"fmt"
24+
"strings"
2425

2526
"github.com/plgd-dev/device/v2/client/core"
2627
"github.com/plgd-dev/device/v2/pkg/net/coap"
@@ -92,7 +93,7 @@ type DeviceWithLinks struct {
9293
}
9394

9495
func (c *Client) getDevicesByIP(ctx context.Context, ip string, expectedDeviceID string) ([]DeviceWithLinks, error) {
95-
devs, err := c.getDeviceByIPWithUpdateCache(ctx, ip, expectedDeviceID)
96+
devs, err := c.getDeviceByIPWithUpdateCache(ctx, strings.Trim(ip, "[]"), expectedDeviceID)
9697
if err != nil {
9798
return nil, err
9899
}

0 commit comments

Comments
 (0)