Line data Source code
1 : import type { ResultItemType } from '@comfyorg/api-client/resultItemTypeSchema'
2 : import { app } from '@/scripts/app'
3 :
4 23 : export function getResourceURL(
5 : subfolder: string,
6 : filename: string,
7 : type: ResultItemType = 'input'
8 : ): string {
9 : const params = [
10 : 'filename=' + encodeURIComponent(filename),
11 : 'type=' + type,
12 : 'subfolder=' + subfolder,
13 : app.getRandParam().substring(1)
14 : ].join('&')
15 :
16 23 : return `/view?${params}`
17 : }
18 :
19 23 : export function splitFilePath(path: string): [string, string] {
20 23 : const folder_separator = path.lastIndexOf('/')
21 23 : if (folder_separator === -1) {
22 23 : return ['', path]
23 : }
24 0 : return [
25 : path.substring(0, folder_separator),
26 : path.substring(folder_separator + 1)
27 : ]
28 : }
|