fix: validate texture asset names server-side

This commit is contained in:
Tom Boullay
2026-04-28 00:17:28 +02:00
parent 2679d29ab4
commit 9dc0232e4a
5 changed files with 72 additions and 48 deletions
+10 -2
View File
@@ -1,15 +1,19 @@
import { getAssetFamily } from './asset-naming'
export type AssetCategory = 'color' | 'roughness' | 'normal' | 'metalness' | 'assets'
export type AssetCategory = 'color' | 'diffuse' | 'roughness' | 'normal' | 'metalness' | 'opacity' | 'assets'
export function classifyAssetCategory(filename: string): AssetCategory {
const name = filename.replace(/\.[^.]+$/, '')
const family = getAssetFamily(name.split('_')[0])
if (family === 'color' || family === 'diffuse') {
if (family === 'color') {
return 'color'
}
if (family === 'diffuse') {
return 'diffuse'
}
if (family === 'roughness') {
return 'roughness'
}
@@ -22,5 +26,9 @@ export function classifyAssetCategory(filename: string): AssetCategory {
return 'metalness'
}
if (family === 'opacity') {
return 'opacity'
}
return 'assets'
}