Skip to content

Commit c30e96c

Browse files
committed
fix: show directory listing instead of error when opening folder path
1 parent 71e4343 commit c30e96c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/pages/package/code/[...path].vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ const currentNode = computed(() => {
9595
9696
const parts = filePath.value.split('/')
9797
let current: PackageFileTree[] | undefined = fileTree.value.tree
98+
let lastFound: PackageFileTree | null = null
9899
99100
for (const part of parts) {
100101
const found: PackageFileTree | undefined = current?.find(n => n.name === part)
101102
if (!found) return null
103+
lastFound = found
102104
if (found.type === 'file') return found
103105
current = found.children
104106
}
105107
106-
return null
108+
return lastFound
107109
})
108110
109111
const isViewingFile = computed(() => currentNode.value?.type === 'file')
@@ -117,8 +119,8 @@ const isFileTooLarge = computed(() => {
117119
118120
// Fetch file content when a file is selected (and not too large)
119121
const fileContentUrl = computed(() => {
120-
// Don't fetch if no file path, file tree not loaded, or file is too large
121-
if (!filePath.value || !fileTree.value || isFileTooLarge.value) {
122+
// Don't fetch if no file path, file tree not loaded, file is too large, or it's a directory
123+
if (!filePath.value || !fileTree.value || isFileTooLarge.value || !isViewingFile.value) {
122124
return null
123125
}
124126
return `/api/registry/file/${packageName.value}/v/${version.value}/${filePath.value}`

0 commit comments

Comments
 (0)