Skip to content

Commit

Permalink
fix(types): relax typing on provider parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Jan 27, 2024
1 parent c809296 commit 1c606ed
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/types/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,25 @@ func ParseProviderStrings(v string) ([]Provider, error) {
parts := strings.Split(v, "+")
addrString := parts[0]
if len(parts) > 1 {
var foundProtocol bool
for _, part := range parts[1:] {
switch part {
case "bitswap":
foundProtocol = true
protocols = append(protocols, metadata.Bitswap{})
case "graphsync":
foundProtocol = true
protocols = append(protocols, &metadata.GraphsyncFilecoinV1{})
case "http":
foundProtocol = true
protocols = append(protocols, metadata.IpfsGatewayHttp{})
default:
return nil, fmt.Errorf("unrecognized protocol: %s", v)
// if we haven't encountered a prootocol string yet, assume this + was in the multiaddr for some reason
// if we have, something is malconstructed
if foundProtocol {
return nil, fmt.Errorf("unrecognized protocol: %s", v)
}
addrString += part
}
}
}
Expand Down

0 comments on commit 1c606ed

Please sign in to comment.