From d7f76f279f916e75fc6c9e95b1a506d713ce9ea4 Mon Sep 17 00:00:00 2001 From: Andrew Gillis <11790789+gammazero@users.noreply.github.com> Date: Tue, 9 Jul 2024 00:54:58 -0700 Subject: [PATCH] Find can handle hex formatted multihashes (#190) Co-authored-by: gammazero --- find.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/find.go b/find.go index 198f6b0..962fb30 100644 --- a/find.go +++ b/find.go @@ -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: