refactor: dedupe extension lowercase query helpers

This commit is contained in:
Peter Steinberger
2026-04-07 11:06:11 +01:00
parent 967ecddfed
commit 5de04bc1d5
8 changed files with 21 additions and 16 deletions

View File

@@ -1,3 +1,4 @@
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime";
import { listMatrixDirectoryGroupsLive, listMatrixDirectoryPeersLive } from "./directory-live.js";
import { isMatrixQualifiedUserId, normalizeMatrixMessagingTarget } from "./matrix/target-ids.js";
import type {
@@ -8,7 +9,7 @@ import type {
} from "./runtime-api.js";
function normalizeLookupQuery(query: string): string {
return query.trim().toLowerCase();
return normalizeOptionalLowercaseString(query) ?? "";
}
function findExactDirectoryMatches(
@@ -20,9 +21,9 @@ function findExactDirectoryMatches(
return [];
}
return matches.filter((match) => {
const id = match.id.trim().toLowerCase();
const name = match.name?.trim().toLowerCase();
const handle = match.handle?.trim().toLowerCase();
const id = normalizeOptionalLowercaseString(match.id);
const name = normalizeOptionalLowercaseString(match.name);
const handle = normalizeOptionalLowercaseString(match.handle);
return normalized === id || normalized === name || normalized === handle;
});
}