refactor(transformers): tighten normalizeBoolean to accept real booleans only

All bool-tagged config fields on the backend are Go bools and serialize
as JSON true/false (e.g. Debug, RequestLog, WebsocketAuth, Disabled,
Websockets, ForceModelPrefix). normalizeBoolean is only called against
those response paths, so the number / string / Boolean(value) fallbacks
never fire.
This commit is contained in:
LTbinglingfeng
2026-05-28 00:41:54 +08:00
Unverified
parent 85c8b34e59
commit 7f29cf2384
+2 -11
View File
@@ -15,17 +15,8 @@ import { buildHeaderObject } from '@/utils/headers';
const isRecord = (value: unknown): value is Record<string, unknown> =>
value !== null && typeof value === 'object' && !Array.isArray(value);
const normalizeBoolean = (value: unknown): boolean | undefined => {
if (value === undefined || value === null) return undefined;
if (typeof value === 'boolean') return value;
if (typeof value === 'number') return value !== 0;
if (typeof value === 'string') {
const trimmed = value.trim().toLowerCase();
if (['true', '1', 'yes', 'y', 'on'].includes(trimmed)) return true;
if (['false', '0', 'no', 'n', 'off'].includes(trimmed)) return false;
}
return Boolean(value);
};
const normalizeBoolean = (value: unknown): boolean | undefined =>
typeof value === 'boolean' ? value : undefined;
const normalizeModelAliases = (models: unknown): ModelAlias[] => {
if (!Array.isArray(models)) return [];