openclaw/src/infra/package-tag.ts
2026-03-02 19:57:33 +00:00

19 lines
399 B
TypeScript

export function normalizePackageTagInput(
value: string | undefined | null,
packageNames: readonly string[],
): string | null {
const trimmed = value?.trim();
if (!trimmed) {
return null;
}
for (const packageName of packageNames) {
const prefix = `${packageName}@`;
if (trimmed.startsWith(prefix)) {
return trimmed.slice(prefix.length);
}
}
return trimmed;
}