mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 02:43:57 +00:00
28 lines
895 B
TypeScript
28 lines
895 B
TypeScript
export function parseQaProgressBooleanEnv(value: string | undefined): boolean | undefined {
|
|
const normalized = value?.trim().toLowerCase();
|
|
if (!normalized) {
|
|
return undefined;
|
|
}
|
|
if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
|
|
return true;
|
|
}
|
|
if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
|
|
return false;
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
export function sanitizeQaProgressValue(value: string): string {
|
|
let normalized = "";
|
|
for (const char of value) {
|
|
const code = char.codePointAt(0);
|
|
if (code === undefined) {
|
|
continue;
|
|
}
|
|
const isControl = code <= 0x1f || (code >= 0x7f && code <= 0x9f);
|
|
normalized += isControl ? " " : char;
|
|
}
|
|
normalized = normalized.replace(/\s+/gu, " ").trim();
|
|
return normalized.length > 0 ? normalized : "<empty>";
|
|
}
|