p2p/dnsdisc: use strings.Cut over strings.IndexByte (#28787)

pull/28804/head^2
ddl 10 months ago committed by GitHub
parent a608c0ac84
commit 1335ba5f28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      p2p/dnsdisc/tree.go

@ -344,11 +344,11 @@ func parseLink(e string) (*linkEntry, error) {
return nil, fmt.Errorf("wrong/missing scheme 'enrtree' in URL")
}
e = e[len(linkPrefix):]
pos := strings.IndexByte(e, '@')
if pos == -1 {
keystring, domain, found := strings.Cut(e, "@")
if !found {
return nil, entryError{"link", errNoPubkey}
}
keystring, domain := e[:pos], e[pos+1:]
keybytes, err := b32format.DecodeString(keystring)
if err != nil {
return nil, entryError{"link", errBadPubkey}

Loading…
Cancel
Save