mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-06-16 21:03:58 +08:00
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:
@@ -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 [];
|
||||
|
||||
Reference in New Issue
Block a user