diff --git a/Endpoints/WorkspaceEndpoint.cs b/Endpoints/WorkspaceEndpoint.cs index 86e6cae..58851d5 100644 --- a/Endpoints/WorkspaceEndpoint.cs +++ b/Endpoints/WorkspaceEndpoint.cs @@ -304,7 +304,7 @@ public static class WorkspaceEndpoint { var drives = System.IO.DriveInfo.GetDrives() .Where(d => d.IsReady) - .Select(d => new { name = d.Name.TrimEnd('\\'), path = d.Name.Replace('\\', '/'), type = "dir" }) + .Select(d => new { name = d.Name.TrimEnd('\\'), path = d.Name.TrimEnd('\\'), type = "dir" }) .ToList(); await ctx.Response.WriteAsJsonAsync(new { current = "", entries = drives }); return; @@ -326,12 +326,12 @@ public static class WorkspaceEndpoint { var name = Path.GetFileName(dir); if (IgnoredDirs.Contains(name)) continue; - entries.Add(new { name, path = dir.Replace('\\', '/'), type = "dir" }); + entries.Add(new { name, path = dir, type = "dir" }); } } catch (UnauthorizedAccessException) { } - await ctx.Response.WriteAsJsonAsync(new { current = targetPath.Replace('\\', '/'), entries }); + await ctx.Response.WriteAsJsonAsync(new { current = targetPath, entries }); } private static async Task HandleBrowseMkdir(HttpContext ctx) @@ -362,7 +362,7 @@ public static class WorkspaceEndpoint } Directory.CreateDirectory(targetPath); - await ctx.Response.WriteAsJsonAsync(new { path = targetPath.Replace('\\', '/'), created = true }); + await ctx.Response.WriteAsJsonAsync(new { path = targetPath, created = true }); } private static async Task HandleRawFile(HttpContext ctx) diff --git a/wwwroot/js/file-explorer.js b/wwwroot/js/file-explorer.js index 1518d20..e966673 100644 --- a/wwwroot/js/file-explorer.js +++ b/wwwroot/js/file-explorer.js @@ -579,10 +579,11 @@ async function fbLoadDir(absPath) { sidebar.innerHTML = '
Leer
'; } - const currentNorm = data.current.replace(/\/+$/, ''); + const currentNorm = data.current.replace(/[\\/]+$/, ''); const atBase = _feState.basePath && currentNorm === _feState.basePath; - const atRoot = currentNorm === '' || currentNorm === '/' || (serverIsWindows && /^[A-Z]:$/i.test(currentNorm)); - document.getElementById('feBack').disabled = atBase || (atRoot && _feState.history.length === 0); + const atDriveList = serverIsWindows && currentNorm === ''; + const atRoot = currentNorm === '' || currentNorm === '/'; + document.getElementById('feBack').disabled = atBase || (atRoot && _feState.history.length === 0) || atDriveList; } catch (e) { sidebar.innerHTML = '
Netzwerk-Fehler
'; } @@ -591,13 +592,13 @@ async function fbLoadDir(absPath) { function fbGoBack() { if (!_feState) return; // Nicht über den basePath hinaus navigieren - const currentNorm = _feState.currentAbsPath.replace(/\/+$/, ''); + const currentNorm = _feState.currentAbsPath.replace(/[\\/]+$/, ''); if (_feState.basePath && currentNorm === _feState.basePath) return; if (_feState.history.length > 0) { const prev = _feState.history.pop(); // Prüfe ob der vorherige Pfad über dem basePath liegt - if (_feState.basePath && !prev.replace(/\/+$/, '').startsWith(_feState.basePath)) { + if (_feState.basePath && !prev.replace(/[\\/]+$/, '').startsWith(_feState.basePath)) { _feState.history.length = 0; fbLoadDir(_feState.basePath); return; @@ -608,10 +609,11 @@ function fbGoBack() { let parent; if (serverIsWindows && /^[A-Z]:$/i.test(currentNorm)) { parent = ''; // Laufwerk → zurück zur Laufwerksauswahl - } else if (serverIsWindows && /^[A-Z]:\/[^/]*$/i.test(currentNorm)) { - parent = currentNorm.substring(0, 2); // z.B. C:/Users → C: + } else if (serverIsWindows && /^[A-Z]:[\\\/][^\\\/]*$/i.test(currentNorm)) { + parent = currentNorm.substring(0, 2); // z.B. C:\Users → C: } else { - parent = currentNorm.includes('/') ? currentNorm.substring(0, currentNorm.lastIndexOf('/')) || (serverIsWindows ? '' : '/') : (serverIsWindows ? '' : '/'); + const lastSep = Math.max(currentNorm.lastIndexOf('/'), currentNorm.lastIndexOf('\\')); + parent = lastSep > 0 ? currentNorm.substring(0, lastSep) : (serverIsWindows ? '' : '/'); } if (parent !== currentNorm) { fbLoadDir(parent);