fix(archive): scope to URL subpath when auto-served at a no-slash directory URL
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) <noreply@anthropic.com>
This commit is contained in:
parent
dbb7f6c9b5
commit
d8459b87c2
1 changed files with 29 additions and 4 deletions
|
|
@ -74,14 +74,39 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-connect to the HTTP server
|
// 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() {
|
async function autoConnectHttpSource() {
|
||||||
var href = window.location.href;
|
var href = window.location.href;
|
||||||
// Strip query string and fragment
|
// Strip query string and fragment
|
||||||
href = href.split('?')[0].split('#')[0];
|
href = href.split('?')[0].split('#')[0];
|
||||||
// Strip the filename to get the directory
|
var baseUrl;
|
||||||
var lastSlash = href.lastIndexOf('/');
|
if (href.endsWith('/')) {
|
||||||
var baseUrl = (lastSlash >= 0) ? href.substring(0, lastSlash + 1) : href + '/';
|
// 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.
|
// Multi-project mode is opt-in via ?projects= in the URL.
|
||||||
// ?projects= absent → not multi-project; scan whatever the URL
|
// ?projects= absent → not multi-project; scan whatever the URL
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue