mirror of
https://github.com/fiatjaf/khatru.git
synced 2026-06-04 09:41:28 +02:00
fix(blossom): handle nil BlobDescriptor in Get and Delete
Refine extension derivation logic by ensuring `bd` is not nil before accessing its type.
This commit is contained in:
committed by
fiatjaf_
parent
3c802caff5
commit
668c41b988
@@ -189,11 +189,11 @@ func (bs BlossomServer) handleGetBlob(w http.ResponseWriter, r *http.Request) {
|
||||
var ext string
|
||||
bd, err := bs.Store.Get(r.Context(), hhash)
|
||||
if err != nil {
|
||||
// can't find the blob, try to get the extension from the URL
|
||||
// can't find the BlobDescriptor, try to get the extension from the URL
|
||||
if len(spl) == 2 {
|
||||
ext = spl[1]
|
||||
}
|
||||
} else {
|
||||
} else if bd != nil {
|
||||
ext = getExtension(bd.Type)
|
||||
}
|
||||
|
||||
@@ -348,11 +348,11 @@ func (bs BlossomServer) handleDelete(w http.ResponseWriter, r *http.Request) {
|
||||
var ext string
|
||||
bd, err := bs.Store.Get(r.Context(), hhash)
|
||||
if err != nil {
|
||||
// can't find the blob, try to get the extension from the URL
|
||||
// can't find the BlobDescriptor, try to get the extension from the URL
|
||||
if len(spl) == 2 {
|
||||
ext = spl[1]
|
||||
}
|
||||
} else {
|
||||
} else if bd != nil {
|
||||
ext = getExtension(bd.Type)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user