refactor: improve path handling in folder viewer

- Updated path splitting logic to retain leading slashes for absolute paths while filtering out empty segments.
- Enhanced parent path reconstruction to ensure correct navigation within the folder structure.
- Improved readability and maintainability of the path management code.
This commit is contained in:
tigeren 2025-08-27 17:16:45 +00:00
parent fcf2b19c80
commit caa0d1eab9
1 changed files with 9 additions and 3 deletions

View File

@ -174,12 +174,18 @@ const FolderViewerPage = () => {
// Don't allow navigation above library root
if (currentPath === libraryRoot) return '';
const pathParts = currentPath.split('/').filter(part => part.length > 0);
// Split path but keep leading slash for absolute paths
const pathParts = currentPath.split('/');
const libraryParts = libraryRoot.split('/').filter(part => part.length > 0);
if (pathParts.length <= libraryParts.length) return '';
// Filter out empty parts but keep structure
const filteredPathParts = pathParts.filter(part => part.length > 0);
return pathParts.slice(0, -1).join('/');
if (filteredPathParts.length <= libraryParts.length) return '';
// Reconstruct absolute path
const parentParts = filteredPathParts.slice(0, -1);
return '/' + parentParts.join('/');
};
const handleBackClick = () => {