mirror of
https://github.com/waku-org/go-multiaddr.git
synced 2025-02-22 19:18:14 +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) {
|
||||
|
||||
// consume trailing slashes
|
||||
s = strings.TrimRight(s, "/")
|
||||
|
||||
b := []byte{}
|
||||
sp := strings.Split(s, "/")
|
||||
|
||||
|
@ -18,6 +18,7 @@ func TestEqual(t *testing.T) {
|
||||
m1 := newMultiaddr(t, "/ip4/127.0.0.1/udp/1234")
|
||||
m2 := 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) {
|
||||
t.Error("should not be equal")
|
||||
@ -38,6 +39,14 @@ func TestEqual(t *testing.T) {
|
||||
if !m1.Equal(m1) {
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user