fix: Windows File-Explorer – Backslashes und Laufwerksübersicht

Pfade werden auf Windows nativ mit Backslashes zurückgegeben statt zu Forward-Slashes konvertiert. Navigation von Laufwerk (C:) zurück zur Laufwerksliste ermöglicht.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MelekiandClaude Opus 4.6 committed 2026-04-17 09:37:06 +02:00
1 parent 53cee67bef
commit eccecf8f14
2 files changed
+14 -12

No files matched your search

+4 -4
View File
@@ -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<object>();
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)
+10 -8
View File
@@ -579,10 +579,11 @@ async function fbLoadDir(absPath) {
sidebar.innerHTML = '<div class="fe-empty">Leer</div>';
}
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 = '<div class="fe-error">Netzwerk-Fehler</div>';
}
@@ -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);