MCPcopy Index your code
hub / github.com/simstudioai/sim / parseStringArray

Function parseStringArray

apps/sim/blocks/blocks/trello.ts:17–49  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

15}
16
17function parseStringArray(value: unknown): string[] | undefined {
18 if (Array.isArray(value)) {
19 const items = value
20 .flatMap((item) => (typeof item === 'string' ? [item.trim()] : []))
21 .filter((item) => item.length > 0)
22
23 return items.length > 0 ? items : undefined
24 }
25
26 if (typeof value !== 'string') {
27 return undefined
28 }
29
30 const trimmed = value.trim()
31 if (trimmed.length === 0) {
32 return undefined
33 }
34
35 if (trimmed.startsWith('[')) {
36 try {
37 const parsed = JSON.parse(trimmed)
38 return parseStringArray(parsed)
39 } catch {
40 return undefined
41 }
42 }
43
44 const items = trimmed
45 .split(',')
46 .map((item) => item.trim())
47 .filter((item) => item.length > 0)
48 return items.length > 0 ? items : undefined
49}
50
51/**
52 * Trello uses a custom token flow and non-UUID credential IDs, so the block keeps

Callers 1

trello.tsFile · 0.70

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected