(value: unknown, axis: string, warnings: string[])
| 33 | // Validate one string[] axis. Non-arrays yield a warning and an empty axis; within an array, only |
| 34 | // non-empty strings are kept (other entries are dropped with a warning). De-duplicates. |
| 35 | const parseStringArrayAxis = (value: unknown, axis: string, warnings: string[]): string[] => { |
| 36 | if (value === undefined) { |
| 37 | return []; |
| 38 | } |
| 39 | if (!Array.isArray(value)) { |
| 40 | warnings.push(`insomnia.permissions.${axis} must be an array of strings; ignoring it (baseline access).`); |
| 41 | return []; |
| 42 | } |
| 43 | const valid: string[] = []; |
| 44 | for (const entry of value) { |
| 45 | if (typeof entry === 'string' && entry.length > 0) { |
| 46 | if (!valid.includes(entry)) { |
| 47 | valid.push(entry); |
| 48 | } |
| 49 | } else { |
| 50 | warnings.push( |
| 51 | `insomnia.permissions.${axis} entries must be non-empty strings; ignoring ${JSON.stringify(entry)}.`, |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 | return valid; |
| 56 | }; |
| 57 | |
| 58 | /** |
| 59 | * Parse the `insomnia` field of a plugin's package.json into validated permissions. `insomniaField` |
no test coverage detected