MCPcopy Create free account
hub / github.com/Kong/insomnia / parseStringArrayAxis

Function parseStringArrayAxis

packages/insomnia/src/common/plugins/permissions.ts:35–56  ·  view source on GitHub ↗
(value: unknown, axis: string, warnings: string[])

Source from the content-addressed store, hash-verified

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.
35const 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`

Callers 1

parsePluginPermissionsFunction · 0.85

Calls 2

stringifyMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected