[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: show directory listing instead of error when opening folder path (#15)

authored by

Azat S. and committed by
GitHub
60d61851 8c6eca27

+5 -3
+5 -3
app/pages/package/code/[...path].vue
··· 96 96 97 97 const parts = filePath.value.split('/') 98 98 let current: PackageFileTree[] | undefined = fileTree.value.tree 99 + let lastFound: PackageFileTree | null = null 99 100 100 101 for (const part of parts) { 101 102 const found: PackageFileTree | undefined = current?.find(n => n.name === part) 102 103 if (!found) return null 104 + lastFound = found 103 105 if (found.type === 'file') return found 104 106 current = found.children 105 107 } 106 108 107 - return null 109 + return lastFound 108 110 }) 109 111 110 112 const isViewingFile = computed(() => currentNode.value?.type === 'file') ··· 118 120 119 121 // Fetch file content when a file is selected (and not too large) 120 122 const fileContentUrl = computed(() => { 121 - // Don't fetch if no file path, file tree not loaded, or file is too large 122 - if (!filePath.value || !fileTree.value || isFileTooLarge.value) { 123 + // Don't fetch if no file path, file tree not loaded, file is too large, or it's a directory 124 + if (!filePath.value || !fileTree.value || isFileTooLarge.value || !isViewingFile.value) { 123 125 return null 124 126 } 125 127 return `/api/registry/file/${packageName.value}/v/${version.value}/${filePath.value}`