mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 09:37:41 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -7,16 +7,24 @@ export function resolveTargetIdFromTabs(
|
||||
tabs: Array<{ targetId: string }>,
|
||||
): TargetIdResolution {
|
||||
const needle = input.trim();
|
||||
if (!needle) return { ok: false, reason: "not_found" };
|
||||
if (!needle) {
|
||||
return { ok: false, reason: "not_found" };
|
||||
}
|
||||
|
||||
const exact = tabs.find((t) => t.targetId === needle);
|
||||
if (exact) return { ok: true, targetId: exact.targetId };
|
||||
if (exact) {
|
||||
return { ok: true, targetId: exact.targetId };
|
||||
}
|
||||
|
||||
const lower = needle.toLowerCase();
|
||||
const matches = tabs.map((t) => t.targetId).filter((id) => id.toLowerCase().startsWith(lower));
|
||||
|
||||
const only = matches.length === 1 ? matches[0] : undefined;
|
||||
if (only) return { ok: true, targetId: only };
|
||||
if (matches.length === 0) return { ok: false, reason: "not_found" };
|
||||
if (only) {
|
||||
return { ok: true, targetId: only };
|
||||
}
|
||||
if (matches.length === 0) {
|
||||
return { ok: false, reason: "not_found" };
|
||||
}
|
||||
return { ok: false, reason: "ambiguous", matches };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user