(value: unknown)
| 69 | * branch on `values.length` for single vs multi behavior. |
| 70 | */ |
| 71 | export function parseMultiValue(value: unknown): string[] { |
| 72 | if (Array.isArray(value)) { |
| 73 | const seen = new Set<string>() |
| 74 | const out: string[] = [] |
| 75 | for (const item of value) { |
| 76 | if (typeof item !== 'string') continue |
| 77 | const trimmed = item.trim() |
| 78 | if (!trimmed || seen.has(trimmed)) continue |
| 79 | seen.add(trimmed) |
| 80 | out.push(trimmed) |
| 81 | } |
| 82 | return out |
| 83 | } |
| 84 | if (typeof value === 'string') { |
| 85 | const seen = new Set<string>() |
| 86 | const out: string[] = [] |
| 87 | for (const part of value.split(',')) { |
| 88 | const trimmed = part.trim() |
| 89 | if (!trimmed || seen.has(trimmed)) continue |
| 90 | seen.add(trimmed) |
| 91 | out.push(trimmed) |
| 92 | } |
| 93 | return out |
| 94 | } |
| 95 | return [] |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Escapes a value for safe interpolation into a Google Drive `q` query string, |
no test coverage detected