mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 11:44:04 +00:00
Extract shared normalization/coercion helpers into private @openclaw/normalization-core workspace package while preserving existing plugin SDK helper subpaths.\n\nAlso keeps direct normalization-core imports internal, wires UI/build/loader resolution, and replaces the slow PR network CodeQL lane with a fast added-line boundary scan while retaining full CodeQL for scheduled/manual runs.\n\nVerification: local moved tests, plugin SDK boundary tests, extension loader tests, agents-support shard, UI build/test, build artifacts, lint, workflow guards, autoreview, and GitHub CI passed on PR head 963d893715.
26 lines
641 B
TypeScript
26 lines
641 B
TypeScript
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
|
|
|
|
const PROFILE_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/i;
|
|
|
|
export function isValidProfileName(value: string): boolean {
|
|
if (!value) {
|
|
return false;
|
|
}
|
|
// Keep it path-safe + shell-friendly.
|
|
return PROFILE_NAME_RE.test(value);
|
|
}
|
|
|
|
export function normalizeProfileName(raw?: string | null): string | null {
|
|
const profile = raw?.trim();
|
|
if (!profile) {
|
|
return null;
|
|
}
|
|
if (normalizeLowercaseStringOrEmpty(profile) === "default") {
|
|
return null;
|
|
}
|
|
if (!isValidProfileName(profile)) {
|
|
return null;
|
|
}
|
|
return profile;
|
|
}
|