Skip to content

Commit b00b4ac

Browse files
author
Aratz M. Lasa
committed
Documented Transcoder functions, and fixed ip6zone string validation
Documented Transcoder functions, and fixed ip6zone string validation
1 parent 64e3415 commit b00b4ac

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

transcoders.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ import (
1414
)
1515

1616
type Transcoder interface {
17+
// Validates and encodes to bytes a multiaddr that's in the string representation.
1718
StringToBytes(string) ([]byte, error)
19+
// Validates and decodes to a string a multiaddr that's in the bytes representation.
1820
BytesToString([]byte) (string, error)
21+
// Validates bytes when parsing a multiaddr that's already in the bytes representation.
1922
ValidateBytes([]byte) error
2023
}
2124

@@ -63,6 +66,9 @@ func ip6zoneStB(s string) ([]byte, error) {
6366
if len(s) == 0 {
6467
return nil, fmt.Errorf("empty ip6zone")
6568
}
69+
if strings.Contains(s, "/") {
70+
return nil, fmt.Errorf("IPv6 zone ID contains '/': %s", s)
71+
}
6672
return []byte(s), nil
6773
}
6874

0 commit comments

Comments
 (0)