@samitouri / QOSami-HFS / commits / 205c9c53

fix: admin/fs: faulty navigation in case of unc path

Massimo Melina committed Sep 23, 2024 at 00:38 UTC 205c9c53dbafc846e27741d4f73e0c5a980fa0f3
1 file changed +4 -2
admin/src/FilePicker.ts
+4 -2
@@ -30,7 +30,7 @@ export default function FilePicker({ onSelect, multiple=true, files=true, folder
30 apiCall('resolve_path', { path: from, closestFolder: true }).then(res => {
31 if (typeof res.path === 'string') {
32 setCwd(res.path)
33 - isWindows.current = res.path[1] === ':'
33 + isWindows.current = res.path[1] === ':' || res.path.startsWith('\\\\') // drive or unc
34 }
35 }).finally(() => setReady(true))
36 }, [from])
@@ -83,7 +83,9 @@ export default function FilePicker({ onSelect, multiple=true, files=true, folder
83 icon: ArrowUpward,
84 onClick() {
85 const cwdND = /[\\/]$/.test(cwd) ? cwd.slice(0,-1) : cwd // exclude final delimiter, if any
86 - const parent = isWindowsDrive(cwdND) ? root : cwdND.slice(0, cwdND.lastIndexOf(pathDelimiter) || 1)
86 + const last = cwdND.lastIndexOf(pathDelimiter)
87 + const isUNCroot = last === 1 // whe cwd is '\\host'
88 + const parent = isWindowsDrive(cwdND) || isUNCroot ? root : cwdND.slice(0, last || 1)
89 setCwd(parent)
90 }
91 }),