mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 07:18:35 +00:00
refactor(browser): unify fill field normalization
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { BrowserFormField } from "../client-actions-core.js";
|
||||
import { normalizeBrowserFormField } from "../form-fields.js";
|
||||
import type { BrowserRouteContext } from "../server-context.js";
|
||||
import { registerBrowserAgentActDownloadRoutes } from "./agent.act.download.js";
|
||||
import { registerBrowserAgentActHookRoutes } from "./agent.act.hooks.js";
|
||||
@@ -190,21 +191,7 @@ export function registerBrowserAgentActRoutes(
|
||||
if (!field || typeof field !== "object") {
|
||||
return null;
|
||||
}
|
||||
const rec = field as Record<string, unknown>;
|
||||
const ref = toStringOrEmpty(rec.ref);
|
||||
const type = toStringOrEmpty(rec.type) || "text";
|
||||
if (!ref) {
|
||||
return null;
|
||||
}
|
||||
const value =
|
||||
typeof rec.value === "string" ||
|
||||
typeof rec.value === "number" ||
|
||||
typeof rec.value === "boolean"
|
||||
? rec.value
|
||||
: undefined;
|
||||
const parsed: BrowserFormField =
|
||||
value === undefined ? { ref, type } : { ref, type, value };
|
||||
return parsed;
|
||||
return normalizeBrowserFormField(field as Record<string, unknown>);
|
||||
})
|
||||
.filter((field): field is BrowserFormField => field !== null);
|
||||
if (!fields.length) {
|
||||
|
||||
Reference in New Issue
Block a user