diff --git a/Services/WorkspaceHelper.cs b/Services/WorkspaceHelper.cs index 7f7ece7..ff31357 100644 --- a/Services/WorkspaceHelper.cs +++ b/Services/WorkspaceHelper.cs @@ -27,12 +27,11 @@ public static class WorkspaceHelper } /// - /// Gibt den relativen Pfad zurück – immer mit Forward-Slashes (für Agent-Output/API). + /// Gibt den relativen Pfad zurück – mit nativen Separatoren (Backslash auf Windows, / auf Linux). /// internal static string GetRelativePath(string relativeTo, string path) { - var rel = Path.GetRelativePath(relativeTo, path); - return IsWindows ? rel.Replace('\\', '/') : rel; + return Path.GetRelativePath(relativeTo, path); } /// diff --git a/wwwroot/index.html b/wwwroot/index.html index a6ba14a..2fcb332 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -701,7 +701,7 @@
- +
diff --git a/wwwroot/js/file-explorer.js b/wwwroot/js/file-explorer.js index e966673..468a2ba 100644 --- a/wwwroot/js/file-explorer.js +++ b/wwwroot/js/file-explorer.js @@ -73,7 +73,8 @@ function openFileExplorer(opts = {}) { // Zum Verzeichnis der initialFile navigieren, oder Root if (_feState.initialFile) { const filePath = _feState.initialFile; - const dir = filePath.includes('/') ? filePath.substring(0, filePath.lastIndexOf('/')) : ''; + const lastSep = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\')); + const dir = lastSep >= 0 ? filePath.substring(0, lastSep) : ''; feLoadDir(dir); } else { feLoadDir(''); @@ -128,7 +129,8 @@ async function feLoadDir(path) { upItem.innerHTML = ' ..'; upItem.addEventListener('click', () => { _feState.history.push(path); - const parent = path.includes('/') ? path.substring(0, path.lastIndexOf('/')) : ''; + const lastSep = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')); + const parent = lastSep >= 0 ? path.substring(0, lastSep) : ''; feLoadDir(parent); }); sidebar.appendChild(upItem); @@ -490,7 +492,7 @@ function openFolderBrowser(opts = {}) { mode: 'folder', onSelect: opts.onSelect || null, currentAbsPath: opts.startPath || '/', - basePath: (opts.basePath || '').replace(/\/+$/, '') || null, + basePath: (opts.basePath || '').replace(/[\\/]+$/, '') || null, history: [] }; @@ -635,7 +637,8 @@ async function fbCreateDir() { return; } - const absPath = _feState.currentAbsPath.replace(/\/$/, '') + '/' + dirName; + const sep = _feState.currentAbsPath.includes('\\') ? '\\' : '/'; + const absPath = _feState.currentAbsPath.replace(/[\\/]+$/, '') + sep + dirName; try { const resp = await fetch(`/api/workspace/browse/mkdir?path=${encodeURIComponent(absPath)}`, { method: 'POST' }); @@ -664,7 +667,8 @@ async function feCreateDir() { return; } - const newPath = _feState.currentPath ? _feState.currentPath + '/' + dirName : dirName; + const sep = _feState.currentPath.includes('\\') ? '\\' : '/'; + const newPath = _feState.currentPath ? _feState.currentPath + sep + dirName : dirName; try { const url = _feApiUrl('mkdir', `path=${encodeURIComponent(newPath)}`);