From 2d508d0d276a243708a62138522c0ab086ea46e9 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 22 Mar 2026 14:54:56 -0500 Subject: [PATCH] Simplify archive.org metadata response parsing --- src/components/ArchiveOrgEmbed.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/ArchiveOrgEmbed.tsx b/src/components/ArchiveOrgEmbed.tsx index f0ab895e..78a9f267 100644 --- a/src/components/ArchiveOrgEmbed.tsx +++ b/src/components/ArchiveOrgEmbed.tsx @@ -16,9 +16,8 @@ function useArchiveOrgDimensions(identifier: string) { const res = await fetch(`https://archive.org/metadata/${identifier}/files`, { signal }); if (!res.ok) return null; - const json: { result?: unknown[] } = await res.json(); - const files: { width?: string; height?: string; source?: string }[] = - (Array.isArray(json) ? json : Array.isArray(json.result) ? json.result : []) as { width?: string; height?: string; source?: string }[]; + const json: { result: { width?: string; height?: string; source?: string }[] } = await res.json(); + const files = json.result; // Prefer the original source file with dimensions, fall back to any file with dimensions. const withDims = files.filter((f) => f.width && f.height);