ai-tube / src /lib /business /getClapAssetSourceType.ts
jbilcke-hf's picture
jbilcke-hf HF staff
let's use @aitube/clap inside AiTube
0d218b1
raw
history blame
585 Bytes
import { ClapAssetSource } from "@aitube/clap"
export function getClapAssetSourceSource(input: string = ""): ClapAssetSource {
const str = `${input || ""}`.trim()
if (!str || !str.length) {
return "EMPTY"
}
if (str.startsWith("https://") || str.startsWith("http://")) {
return "REMOTE"
}
// note that "path" assets are potentially a security risk, they need to be treated with care
if (str.startsWith("/") || str.startsWith("../") || str.startsWith("./")) {
return "PATH"
}
if (str.startsWith("data:")) {
return "DATA"
}
return "PROMPT"
}