diff --git a/archive/js/table.js b/archive/js/table.js index ce5034f..4ee09b3 100644 --- a/archive/js/table.js +++ b/archive/js/table.js @@ -345,9 +345,28 @@ */ async function showFilePreview(file) { const ext = file.extension.toLowerCase(); - + try { - const url = await getFileBlobUrl(file); + // For HTML preview, prefer the file's real server URL over a + // blob URL when available (zddc-server-backed archives have + // file.url set; local FileSystemAccessAPI mode doesn't). + // + // Why it matters: HTML files in an archive often link to + // sibling/parent paths via relative URLs — e.g. + // ../.archive/.html — which zddc-server intercepts + // and resolves. From a blob: URL the relative resolution + // produces blob:.../.archive/X.html, which never reaches the + // server. Loading the iframe from the actual https://zddc.../ + // URL means relative links resolve back to the server and the + // .archive interception fires as designed. + // + // Other types (pdf, images rendered via canvas / iframe etc.) + // are content-only — they don't depend on relative URLs — so + // a blob URL is fine. + const isHtml = ext === 'html' || ext === 'htm'; + const url = (isHtml && file.url) + ? file.url + : await getFileBlobUrl(file); // Mirror the parent window's theme in the popup const parentTheme = document.documentElement.getAttribute('data-theme') || ''; @@ -511,7 +530,7 @@ ${(ext === 'pdf' || ext === 'html' || ext === 'htm') - ? '' + ? '' : '
Loading preview...
'}