mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: look for longer extension names
This commit is contained in:
parent
2ac17d677a
commit
f54f2ea440
1 changed files with 11 additions and 4 deletions
|
|
@ -52,10 +52,17 @@ export function getFolderIconSrc(node: TreeNode, open: boolean) {
|
|||
const { filenameIndex, fileExtensionIndex } = parseFileIconMapCSV()
|
||||
|
||||
export function getFileIconSrc(node: TreeNode) {
|
||||
const name =
|
||||
filenameIndex.get(node.name.toLowerCase()) ||
|
||||
fileExtensionIndex.get((node.name.split('.').pop() as string).toLowerCase())
|
||||
return getIconSrc('file', name)
|
||||
const fileName = node.name.toLowerCase()
|
||||
let iconName = filenameIndex.get(fileName)
|
||||
if (!iconName) {
|
||||
const tail = fileName.split('.')
|
||||
tail.shift()
|
||||
while (!iconName && tail.length > 0) {
|
||||
iconName = fileExtensionIndex.get(tail.join('.'))
|
||||
tail.shift()
|
||||
}
|
||||
}
|
||||
return getIconSrc('file', iconName)
|
||||
}
|
||||
|
||||
export function getIconSrc(type: 'folder' | 'file', name: string = 'default', open?: boolean) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue