mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
fix: handle windows paths in media extension parsing
This commit is contained in:
@@ -174,12 +174,14 @@ describe('formatUtil', () => {
|
||||
it('returns a normalized lowercase extension when present', () => {
|
||||
expect(getFileExtension('mesh.PLY')).toBe('ply')
|
||||
expect(getFileExtension('/path/to/file.glb')).toBe('glb')
|
||||
expect(getFileExtension('C:\\path.with.dot\\file.OBJ')).toBe('obj')
|
||||
})
|
||||
|
||||
it('returns null when no extension is present', () => {
|
||||
expect(getFileExtension('README')).toBe(null)
|
||||
expect(getFileExtension('')).toBe(null)
|
||||
expect(getFileExtension(undefined)).toBe(null)
|
||||
expect(getFileExtension('C:\\path.with.dot\\README')).toBe(null)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -630,7 +630,7 @@ export function getFileExtension(
|
||||
filename: string | null | undefined
|
||||
): string | null {
|
||||
if (!filename) return null
|
||||
const fullFilename = filename.split('/').pop() ?? filename
|
||||
const fullFilename = filename.split(/[/\\]/).pop() ?? filename
|
||||
const dotIndex = fullFilename.lastIndexOf('.')
|
||||
if (dotIndex <= 0) return null
|
||||
return fullFilename.slice(dotIndex + 1).toLowerCase()
|
||||
|
||||
Reference in New Issue
Block a user