mirror of
https://github.com/waku-org/go-multiaddr.git
synced 2025-02-23 03:28:12 +00:00
ignore trailing slashes
This commit is contained in:
parent
351b5d0f14
commit
2a572df05c
4
codec.go
4
codec.go
@ -9,6 +9,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func stringToBytes(s string) ([]byte, error) {
|
func stringToBytes(s string) ([]byte, error) {
|
||||||
|
|
||||||
|
// consume trailing slashes
|
||||||
|
s = strings.TrimRight(s, "/")
|
||||||
|
|
||||||
b := []byte{}
|
b := []byte{}
|
||||||
sp := strings.Split(s, "/")
|
sp := strings.Split(s, "/")
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ func TestEqual(t *testing.T) {
|
|||||||
m1 := newMultiaddr(t, "/ip4/127.0.0.1/udp/1234")
|
m1 := newMultiaddr(t, "/ip4/127.0.0.1/udp/1234")
|
||||||
m2 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234")
|
m2 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234")
|
||||||
m3 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234")
|
m3 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234")
|
||||||
|
m4 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234/")
|
||||||
|
|
||||||
if m1.Equal(m2) {
|
if m1.Equal(m2) {
|
||||||
t.Error("should not be equal")
|
t.Error("should not be equal")
|
||||||
@ -38,6 +39,14 @@ func TestEqual(t *testing.T) {
|
|||||||
if !m1.Equal(m1) {
|
if !m1.Equal(m1) {
|
||||||
t.Error("should be equal")
|
t.Error("should be equal")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !m2.Equal(m4) {
|
||||||
|
t.Error("should be equal")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !m4.Equal(m3) {
|
||||||
|
t.Error("should be equal")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStringToBytes(t *testing.T) {
|
func TestStringToBytes(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user