File size: 578 Bytes
f42b4a1
e02a62b
f42b4a1
e02a62b
24bea92
 
 
 
 
 
e02a62b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { ClapAssetSource } from "./types"

export function getClapAssetSourceType(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"
}