From d8459b87c2d064267b3009755f1ff834471b6621 Mon Sep 17 00:00:00 2001 From: ZDDC Date: Mon, 11 May 2026 11:47:17 -0500 Subject: [PATCH] fix(archive): scope to URL subpath when auto-served at a no-slash directory URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When zddc-server auto-serves the archive tool at a sub-folder URL (e.g. /Project-1/Archive/PartyA/Issued, no trailing slash, no archive.html filename), the tool's autoConnectHttpSource was stripping the last URL segment under the assumption it was a filename. Result: archive scanned the PARENT directory (/PartyA/) instead of /Issued/, showing transmittals from sibling folders the user hadn't asked for. Fix: detect the URL shape before deciding what the scan root is. - Trailing slash → URL is already a directory; use as-is. - Last segment has a dot → filename (archive.html); strip to parent. - Last segment has no dot → bare directory name (auto-served URL); treat the entire path as the scan root and append '/'. Now /Project-1/Archive/PartyA/Issued shows only the transmittal folders inside Issued/ — the locally-mounted-folder experience the user expected. Co-Authored-By: Claude Opus 4.7 (1M context) --- archive/js/app.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/archive/js/app.js b/archive/js/app.js index e7500de..920b8cf 100644 --- a/archive/js/app.js +++ b/archive/js/app.js @@ -74,14 +74,39 @@ } // Auto-connect to the HTTP server - // Derives the base URL from the current page's location + // Derives the base URL from the current page's location. + // + // Two URL shapes can serve the archive tool: + // (a) Filename-style: /Project-1/Archive/PartyA/archive.html + // (b) Auto-served: /Project-1/Archive/PartyA/Issued + // + // For (a) the URL ends with a filename (`*.html`) and the + // archive's scan root is the parent directory. For (b) the URL + // path IS the directory; trying to strip the last segment would + // wrongly scan the parent. Detect (b) by checking whether the + // path's last segment looks like a file (has a dot + extension). async function autoConnectHttpSource() { var href = window.location.href; // Strip query string and fragment href = href.split('?')[0].split('#')[0]; - // Strip the filename to get the directory - var lastSlash = href.lastIndexOf('/'); - var baseUrl = (lastSlash >= 0) ? href.substring(0, lastSlash + 1) : href + '/'; + var baseUrl; + if (href.endsWith('/')) { + // Directory URL, e.g. /Project-1/archive/ or / + baseUrl = href; + } else { + var lastSlash = href.lastIndexOf('/'); + var lastSegment = lastSlash >= 0 ? href.substring(lastSlash + 1) : href; + // A "filename" has a dot in its last segment. A bare + // directory name (e.g. "Issued") doesn't. Don't be fooled + // by dots in domain names — lastSlash is past the host. + if (lastSegment.indexOf('.') >= 0) { + baseUrl = href.substring(0, lastSlash + 1); + } else { + // Auto-served at a directory URL with no trailing + // slash. Treat the whole path as the scan root. + baseUrl = href + '/'; + } + } // Multi-project mode is opt-in via ?projects= in the URL. // ?projects= absent → not multi-project; scan whatever the URL