Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import { commonMessages } from '#ui/utils/common-messages'

import { injectFileManager } from '../providers/file-manager'
import type { FileContextMenuOption, FileItem } from '../types'
import { joinDisplayPath } from '../utils'

const { formatMessage } = useVIntl()
const { addNotification } = injectNotificationManager()
Expand Down Expand Up @@ -129,9 +130,7 @@ function handleCopyFilename() {

function getFullPath() {
if (!currentItem.value) return ''
const basePath = ctx.basePath?.value
const itemPath = currentItem.value.path
return basePath ? `${basePath}/${itemPath}`.replace(/\/+/g, '/') : itemPath
return joinDisplayPath(ctx.basePath?.value, currentItem.value.path)
}

function handleCopyPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ import {
} from '../composables/file-drag-state'
import { injectFileManager } from '../providers/file-manager'
import type { FileItem } from '../types'
import { joinDisplayPath } from '../utils'

const { formatMessage } = useVIntl()
const { addNotification } = injectNotificationManager()
Expand Down Expand Up @@ -204,8 +205,7 @@ const fileExtension = computed(() => getFileExtension(props.name))
const isZip = computed(() => fileExtension.value === 'zip')

function getFullPath() {
const basePath = ctx.basePath?.value
return basePath ? `${basePath}/${props.path}`.replace(/\/+/g, '/') : props.path
return joinDisplayPath(ctx.basePath?.value, props.path)
}

const menuOptions = computed(() => {
Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/layouts/shared/files-tab/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function joinDisplayPath(basePath: string | undefined, itemPath: string) {
if (!basePath) return itemPath

const separator = basePath.includes('\\') ? '\\' : '/'
const path = itemPath.replace(/^[\\/]+/, '').replace(/[\\/]+/g, separator)
const base = basePath.replace(/[\\/]+$/, '')

return path ? `${base}${separator}${path}` : basePath
}
Loading