fix: bad link with system-integration #629

Massimo Melina committed Jun 15, 2024 at 00:01 UTC f7e4ca2df7f06966add7d119b43411f00e516738
1 file changed +5 -3
src/api.vfs.ts
+5 -3
@@ -6,8 +6,10 @@ import _ from 'lodash'
6 import { mkdir, stat } from 'fs/promises'
7 import { ApiError, ApiHandlers } from './apiMiddleware'
8 import { dirname, extname, join, resolve } from 'path'
9 -import { dirStream, enforceFinal, isDirectory, isValidFileName, isWindowsDrive, makeMatcher, PERM_KEYS,
10 - VfsNodeAdminSend } from './misc'
9 +import {
10 + dirStream, enforceFinal, enforceStarting, isDirectory, isValidFileName, isWindowsDrive, makeMatcher, PERM_KEYS,
11 + VfsNodeAdminSend
12 +} from './misc'
13 import { IS_WINDOWS, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR, HTTP_CONFLICT, HTTP_NOT_ACCEPTABLE } from './const'
14 import { getDiskSpaces, getDiskSpaceSync, getDrives } from './util-os'
15 import { getBaseUrlOrDefault, getServerStatus } from './listen'
@@ -129,7 +131,7 @@ const apis: ApiHandlers = {
131 ;(parentNode.children ||= []).unshift(child)
132 saveVfs()
133 const link = rest.url ? undefined : await getBaseUrlOrDefault()
132 - + (parent ? enforceFinal('/', parent) : '/')
134 + + (parent ? enforceStarting('/', enforceFinal('/', parent)) : '/')
135 + encodeURIComponent(getNodeName(child))
136 + (isDir ? '/' : '')
137 return { name, link }