fix some for iam

This commit is contained in:
Montech
2026-10-07 16:45:36 +03:30
parent a72fa607a5
commit 5223de313a
25 changed files with 823 additions and 38 deletions
+18
View File
@@ -26,3 +26,21 @@ export function envOrNull(name: string): string | null {
const trimmed = typeof raw === 'string' ? raw.trim() : '';
return trimmed === '' ? null : trimmed;
}
/** Comma-separated env list. Blank entries are dropped. */
export function envList(name: string): string[] {
const raw = envOrNull(name);
if (!raw) return [];
return raw.split(',').map((item) => item.trim()).filter(Boolean);
}
/**
* Exact string match. A requested URI that is not in the list is refused
* (null) instead of being replaced by another app's address.
* With no request, the first configured value is used.
*/
export function pickExactUri(requested: string | undefined, allowed: Array<string | null>): string | null {
const unique = [...new Set(allowed.filter((item): item is string => Boolean(item)))];
if (requested) return unique.includes(requested) ? requested : null;
return unique[0] ?? null;
}