fix: improve path handling in toEntryInfo function to correctly use entry.uri for reliable path resolution

This commit is contained in:
Jaime Idolpx 2026-06-07 18:32:13 -04:00
parent d1270bc604
commit e81974e9ff

View File

@ -132,7 +132,13 @@ function pathFromUri(uri: string, baseUrl: string): string {
} }
function toEntryInfo(e: WebDAVEntry, baseUrl: string): EntryInfo { function toEntryInfo(e: WebDAVEntry, baseUrl: string): EntryInfo {
const rawPath = e.path && e.path.length > 0 ? e.path : e.uri; // The vendored `webdav-component` computes `entry.path` by stripping
// `baseUrl.length` from the href — that only works when the server
// sends absolute hrefs (e.g. `http://localhost/sd/foo`). When the
// server sends relative hrefs (`/sd/foo`), the strip chops off the
// start of the path. Use `entry.uri` directly instead, which the
// parser sets verbatim from the href and is always reliable.
const rawPath = (e.uri && e.uri.length > 0 ? e.uri : e.path) || '';
const fullPath = pathFromUri(rawPath, baseUrl); const fullPath = pathFromUri(rawPath, baseUrl);
// Prefer the server-provided displayname when it looks like a leaf // Prefer the server-provided displayname when it looks like a leaf
// (no slashes). Some servers (notably older webdav3.py) used to // (no slashes). Some servers (notably older webdav3.py) used to