mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 15:20:21 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -59,18 +59,40 @@ const PLATFORM_DEFAULTS: Record<string, string[]> = {
|
||||
|
||||
function normalizePlatformId(platform?: string, deviceFamily?: string): string {
|
||||
const raw = (platform ?? "").trim().toLowerCase();
|
||||
if (raw.startsWith("ios")) return "ios";
|
||||
if (raw.startsWith("android")) return "android";
|
||||
if (raw.startsWith("mac")) return "macos";
|
||||
if (raw.startsWith("darwin")) return "macos";
|
||||
if (raw.startsWith("win")) return "windows";
|
||||
if (raw.startsWith("linux")) return "linux";
|
||||
if (raw.startsWith("ios")) {
|
||||
return "ios";
|
||||
}
|
||||
if (raw.startsWith("android")) {
|
||||
return "android";
|
||||
}
|
||||
if (raw.startsWith("mac")) {
|
||||
return "macos";
|
||||
}
|
||||
if (raw.startsWith("darwin")) {
|
||||
return "macos";
|
||||
}
|
||||
if (raw.startsWith("win")) {
|
||||
return "windows";
|
||||
}
|
||||
if (raw.startsWith("linux")) {
|
||||
return "linux";
|
||||
}
|
||||
const family = (deviceFamily ?? "").trim().toLowerCase();
|
||||
if (family.includes("iphone") || family.includes("ipad") || family.includes("ios")) return "ios";
|
||||
if (family.includes("android")) return "android";
|
||||
if (family.includes("mac")) return "macos";
|
||||
if (family.includes("windows")) return "windows";
|
||||
if (family.includes("linux")) return "linux";
|
||||
if (family.includes("iphone") || family.includes("ipad") || family.includes("ios")) {
|
||||
return "ios";
|
||||
}
|
||||
if (family.includes("android")) {
|
||||
return "android";
|
||||
}
|
||||
if (family.includes("mac")) {
|
||||
return "macos";
|
||||
}
|
||||
if (family.includes("windows")) {
|
||||
return "windows";
|
||||
}
|
||||
if (family.includes("linux")) {
|
||||
return "linux";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
@@ -85,7 +107,9 @@ export function resolveNodeCommandAllowlist(
|
||||
const allow = new Set([...base, ...extra].map((cmd) => cmd.trim()).filter(Boolean));
|
||||
for (const blocked of deny) {
|
||||
const trimmed = blocked.trim();
|
||||
if (trimmed) allow.delete(trimmed);
|
||||
if (trimmed) {
|
||||
allow.delete(trimmed);
|
||||
}
|
||||
}
|
||||
return allow;
|
||||
}
|
||||
@@ -96,7 +120,9 @@ export function isNodeCommandAllowed(params: {
|
||||
allowlist: Set<string>;
|
||||
}): { ok: true } | { ok: false; reason: string } {
|
||||
const command = params.command.trim();
|
||||
if (!command) return { ok: false, reason: "command required" };
|
||||
if (!command) {
|
||||
return { ok: false, reason: "command required" };
|
||||
}
|
||||
if (!params.allowlist.has(command)) {
|
||||
return { ok: false, reason: "command not allowlisted" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user