]> git.maquefel.me Git - brevno-suite/hugo/commit
parser/metadecoders: Add empty /data JSON file as empty map
authorAcClassic <cantillo.trd@gmail.com>
Mon, 12 Dec 2022 17:12:46 +0000 (18:12 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 14 Dec 2022 17:03:47 +0000 (18:03 +0100)
commite30d711c29b3a8e93a2e2062149d8f8d9c841f5e
tree34d621c92dada5b91a4a14939cc02b71102caece
parentad2059878a8d6ace9669ccc5ff0a8d4e5811ad37
parser/metadecoders: Add empty /data JSON file as empty map

When fetching JSON files from the /data folder that are empty they will
be added as empty map[string]any. This makes sure that no empty JSON
file causes the site to crash because of a failed unmarshal. This
happens because empty is not a valid JSON string. It is therefore
important to check the lenght of the data before passing it to the JSON
unmarshal function.

Fixes #8601
parser/metadecoders/decoder.go
parser/metadecoders/decoder_test.go