mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 14:52:09 +03:00
Scoped to guardrails/security: dropped the unrelated js-yaml/tar/shell-quote/ brace-expansion override bumps, and isolated sanitizer-residual-policy.test.ts to a tmp DATA_DIR so it no longer touches the real storage.sqlite. Co-authored-by: RaviTharuma <RaviTharuma@users.noreply.github.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: rafaumeu <rafael.zendron22@gmail.com>
22 lines
655 B
TypeScript
22 lines
655 B
TypeScript
/**
|
|
* Shared env/flag boolean parsing for security guards.
|
|
*
|
|
* Truthy: true / 1 / yes / on (case-insensitive, trimmed)
|
|
* Falsy: false / 0 / no / off
|
|
* Unset/empty/unknown → fallback
|
|
*
|
|
* @module shared/utils/envBoolean
|
|
*/
|
|
|
|
export function parseEnvBoolean(
|
|
value: string | undefined | null,
|
|
fallback: boolean
|
|
): boolean {
|
|
if (value === undefined || value === null) return fallback;
|
|
const normalized = String(value).trim().toLowerCase();
|
|
if (normalized === "") return fallback;
|
|
if (["1", "true", "yes", "on"].includes(normalized)) return true;
|
|
if (["0", "false", "no", "off"].includes(normalized)) return false;
|
|
return fallback;
|
|
}
|