Taking care of empty responses

fixes "unexpected token at ''" appearing after fetching a list of snapshots
This commit is contained in:
Felipe 2025-02-09 16:24:02 +00:00 committed by GitHub
parent 7142be5c16
commit 019534794c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,7 +10,9 @@ module ArchiveAPI
begin
response = http.get(request_url)
json = JSON.parse(response.body)
body = response.body.to_s.strip
return [] if body.empty?
json = JSON.parse(body)
# Check if the response contains the header ["timestamp", "original"]
json.shift if json.first == ["timestamp", "original"]