refactor: dedupe extension lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 22:09:21 +01:00
parent a44a26f0a0
commit 2187b19d7e
17 changed files with 41 additions and 35 deletions

View File

@@ -47,7 +47,7 @@ export function normalizeIMessageHandle(raw: string): string {
return "";
}
const value = trimmed.slice(prefix.length).trim();
return `${prefix.toLowerCase()}${value}`;
return `${normalizeLowercaseStringOrEmpty(prefix)}${value}`;
}
if (trimmed.includes("@")) {
return normalizeLowercaseStringOrEmpty(trimmed);

View File

@@ -3,6 +3,7 @@ import { loadConfig } from "openclaw/plugin-sdk/config-runtime";
import { runCommandWithTimeout } from "openclaw/plugin-sdk/process-runtime";
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
import { detectBinary } from "openclaw/plugin-sdk/setup";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import { createIMessageRpcClient } from "./client.js";
import { DEFAULT_IMESSAGE_PROBE_TIMEOUT_MS } from "./constants.js";
@@ -35,7 +36,7 @@ async function probeRpcSupport(cliPath: string, timeoutMs: number): Promise<RpcS
try {
const result = await runCommandWithTimeout([cliPath, "rpc", "--help"], { timeoutMs });
const combined = `${result.stdout}\n${result.stderr}`.trim();
const normalized = combined.toLowerCase();
const normalized = normalizeLowercaseStringOrEmpty(combined);
if (normalized.includes("unknown command") && normalized.includes("rpc")) {
const fatal = {
supported: false,

View File

@@ -21,7 +21,7 @@ function normalizeIMessageTestHandle(raw: string): string {
}
if (/^(chat_id:|chat_guid:|chat_identifier:)/i.test(trimmed)) {
return trimmed.replace(/^(chat_id:|chat_guid:|chat_identifier:)/i, (match) =>
match.toLowerCase(),
normalizeLowercaseStringOrEmpty(match),
);
}
if (trimmed.includes("@")) {