dduf-check / src /lib /check-filename.ts
coyotte508's picture
coyotte508 HF staff
Also add .model files
a5904e1 verified
raw
history blame
501 Bytes
export function checkFilename(filename: string) {
if (
!filename.endsWith('.safetensors') &&
!filename.endsWith('.json') &&
!filename.endsWith('.gguf') &&
!filename.endsWith('.txt') &&
!filename.endsWith('.model') &&
!filename.endsWith('/')
) {
throw new Error('Files must have a .safetensors, .txt, .model, .gguf or .json extension');
}
const split = filename.split('/');
if (split.length > 2) {
throw new Error('Files must be only one level deep, not more');
}
}