refactor: dedupe misc lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 22:22:46 +01:00
parent 775b78e186
commit 67dc6e82b9
26 changed files with 112 additions and 77 deletions

View File

@@ -19,6 +19,7 @@ import {
runSshSandboxCommand,
sanitizeEnvVars,
} from "openclaw/plugin-sdk/sandbox";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import {
buildExecRemoteCommand,
buildRemoteCommand,
@@ -504,8 +505,7 @@ function resolveOpenShellPluginConfigFromConfig(
function buildOpenShellSandboxName(scopeKey: string): string {
const trimmed = scopeKey.trim() || "session";
const safe = trimmed
.toLowerCase()
const safe = normalizeLowercaseStringOrEmpty(trimmed)
.replace(/[^a-z0-9._-]+/g, "-")
.replace(/^-+|-+$/g, "")
.slice(0, 32);

View File

@@ -1,12 +1,13 @@
import fs from "node:fs/promises";
import path from "node:path";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
export const DEFAULT_OPEN_SHELL_MIRROR_EXCLUDE_DIRS = ["hooks", "git-hooks", ".git"] as const;
const COPY_TREE_FS_CONCURRENCY = 16;
function createExcludeMatcher(excludeDirs?: readonly string[]) {
const excluded = new Set((excludeDirs ?? []).map((d) => d.toLowerCase()));
return (name: string) => excluded.has(name.toLowerCase());
const excluded = new Set((excludeDirs ?? []).map((d) => normalizeLowercaseStringOrEmpty(d)));
return (name: string) => excluded.has(normalizeLowercaseStringOrEmpty(name));
}
function createConcurrencyLimiter(limit: number) {