mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 20:53:55 +00:00
* refactor: consolidate exact boolean parsing * test: fix normalization subpath resolution * fix: resolve normalization boolean subpath
18 lines
438 B
TypeScript
18 lines
438 B
TypeScript
/** Parses booleans and case-insensitive `true`/`false` string tokens. */
|
|
export function parseBoolean(value: unknown): boolean | undefined {
|
|
if (typeof value === "boolean") {
|
|
return value;
|
|
}
|
|
if (typeof value !== "string") {
|
|
return undefined;
|
|
}
|
|
const normalized = value.trim().toLowerCase();
|
|
if (normalized === "true") {
|
|
return true;
|
|
}
|
|
if (normalized === "false") {
|
|
return false;
|
|
}
|
|
return undefined;
|
|
}
|