Line data Source code
1 : import { reportError } from '@comfyorg/telemetry/reportError'
2 :
3 26 : export function extensionNameFromPath(path: string): string {
4 26 : const encodedName = path.split('/').filter(Boolean).at(-1) ?? path
5 26 : try {
6 26 : return decodeURIComponent(encodedName)
7 : } catch {
8 0 : return encodedName
9 : }
10 : }
11 :
12 3 : export function normalizeDisabledExtensionPaths(value: unknown): string[] {
13 3 : if (value === undefined) return []
14 3 : if (
15 : Array.isArray(value) &&
16 : value.every((path): path is string => typeof path === 'string')
17 : ) {
18 3 : return value
19 : }
20 :
21 0 : reportError(
22 : new TypeError('Disabled extension paths must be an array of strings'),
23 : {
24 : errorType: 'invalid_extension_path_setting',
25 : surface: 'platform',
26 : level: 'warning'
27 : }
28 : )
29 0 : return []
30 : }
|