···96969797 const parts = filePath.value.split('/')
9898 let current: PackageFileTree[] | undefined = fileTree.value.tree
9999+ let lastFound: PackageFileTree | null = null
99100100101 for (const part of parts) {
101102 const found: PackageFileTree | undefined = current?.find(n => n.name === part)
102103 if (!found) return null
104104+ lastFound = found
103105 if (found.type === 'file') return found
104106 current = found.children
105107 }
106108107107- return null
109109+ return lastFound
108110})
109111110112const isViewingFile = computed(() => currentNode.value?.type === 'file')
···118120119121// Fetch file content when a file is selected (and not too large)
120122const fileContentUrl = computed(() => {
121121- // Don't fetch if no file path, file tree not loaded, or file is too large
122122- if (!filePath.value || !fileTree.value || isFileTooLarge.value) {
123123+ // Don't fetch if no file path, file tree not loaded, file is too large, or it's a directory
124124+ if (!filePath.value || !fileTree.value || isFileTooLarge.value || !isViewingFile.value) {
123125 return null
124126 }
125127 return `/api/registry/file/${packageName.value}/v/${version.value}/${filePath.value}`