Skip to content

Commit

Permalink
Find can handle hex formatted multihashes (#190)
Browse files Browse the repository at this point in the history
Co-authored-by: gammazero <[email protected]>
  • Loading branch information
gammazero and gammazero authored Jul 9, 2024
1 parent a7b6c48 commit d7f76f2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions find.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ func (s *server) findMultihashSubtree(w http.ResponseWriter, r *http.Request, en
smh := path.Base(r.URL.Path)
mh, err := multihash.FromB58String(smh)
if err != nil {
http.Error(w, "invalid multihash: "+err.Error(), http.StatusBadRequest)
return
if errors.Is(err, multihash.ErrInvalidMultihash) {
mh, err = multihash.FromHexString(smh)
}
if err != nil {
http.Error(w, "invalid multihash: "+err.Error(), http.StatusBadRequest)
return
}
}
s.find(w, r, mh, encrypted)
default:
Expand Down

0 comments on commit d7f76f2

Please sign in to comment.