Skip to content

Commit

Permalink
respond with b58 decoding error if both b58 and hex decoding errors h…
Browse files Browse the repository at this point in the history
…appen
  • Loading branch information
gammazero committed Jul 9, 2024
1 parent f32ba4e commit a211202
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions find.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ 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 {
if errors.Is(err, multihash.ErrInvalidMultihash) {
mh, err = multihash.FromHexString(smh)
}
if err != nil {
var hexErr error
mh, hexErr = multihash.FromHexString(smh)
if hexErr != nil {
http.Error(w, "invalid multihash: "+err.Error(), http.StatusBadRequest)
return
}
Expand Down

0 comments on commit a211202

Please sign in to comment.