fix some for iam
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user